This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add remaining boosts backend and stat boosts
- Loading branch information
1 parent
7045191
commit 41e5972
Showing
10 changed files
with
97 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
local Players = game:GetService "Players" | ||
local ReplicatedStorage = game:GetService "ReplicatedStorage" | ||
local ServerScriptService = game:GetService "ServerScriptService" | ||
|
||
local Remotes = require(ReplicatedStorage.Common.Remotes) | ||
local store = require(ServerScriptService.Server.State.Store) | ||
local actions = require(ServerScriptService.Server.State.Actions) | ||
local selectors = require(ReplicatedStorage.Common.State.selectors) | ||
local clockUtils = require(ReplicatedStorage.Common.Utils.ClockUtils) | ||
|
||
Remotes.Server:Get("UseBoost"):Connect(function(player, boostName) | ||
if selectors.getBoostCount(store:getState(), player.Name, boostName) < 1 then | ||
return | ||
end | ||
store:dispatch(actions.incrementPlayerBoostCount(player.Name, boostName, -1)) | ||
store:dispatch(actions.applyBoostToPlayer(player.Name, boostName)) | ||
end) | ||
|
||
task.spawn(function() | ||
while true do | ||
local currentState = store:getState() | ||
for _, player in Players:GetPlayers() do | ||
if not selectors.isPlayerLoaded(currentState, player.Name) then | ||
continue | ||
end | ||
local activeBoosts = selectors.getActiveBoosts(currentState, player.Name) | ||
|
||
for boostName, boostData in activeBoosts do | ||
if not clockUtils.hasTimeLeft(boostData.StartTime, boostData.Duration) then | ||
store:dispatch(actions.removeBoostFromPlayer(player.Name, boostName)) | ||
end | ||
end | ||
end | ||
task.wait(1) | ||
end | ||
end) | ||
|
||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
return { | ||
hasTimeLeft = function(startTime, duration) | ||
return (os.time() - startTime) < duration | ||
end, | ||
getFormattedRemainingTime = function(startTime, duration) | ||
local timeLeft = duration - (os.time() - startTime) | ||
local minutes = math.floor(timeLeft / 60) | ||
|
||
if minutes < 1 then | ||
return "<1m" | ||
else | ||
return minutes .. "m" | ||
end | ||
end, | ||
} |