Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Add robux pets
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Nov 20, 2023
1 parent 40c64fb commit e51dba1
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 13 deletions.
20 changes: 12 additions & 8 deletions src/client/UI/BillboardShops/EggShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ local function createAndStartShakes(eggImages: { GuiObject }): ()
end
end

local function createSizeTween(constraint: UISizeConstraint, size: number): Tween
return TweenService:Create(constraint, TweenInfo.new(0.5), {
local function createSizeTween(constraint: UISizeConstraint, size: number, tweenTime: number): Tween
return TweenService:Create(constraint, TweenInfo.new(tweenTime), {
MinSize = size,
})
end
Expand Down Expand Up @@ -189,7 +189,8 @@ local function configureHatchUI(asyncResults, single: boolean, areaName: string)

local sizeTween = createSizeTween(
uiToShow["Pet" .. i].UISizeConstraint,
uiToShow["Pet" .. i].UISizeConstraint.MaxSize
uiToShow["Pet" .. i].UISizeConstraint.MaxSize,
0.5
)
sizeTween:Play()
enableAndSpinRarityBackground(uiToShow["Pet" .. i], pet.RarityName.Value)
Expand All @@ -200,7 +201,7 @@ local function configureHatchUI(asyncResults, single: boolean, areaName: string)

local lastSizeTween
for i in detailedResults do
local sizeTween = createSizeTween(uiToShow["Pet" .. i].UISizeConstraint, oldMinSize)
local sizeTween = createSizeTween(uiToShow["Pet" .. i].UISizeConstraint, oldMinSize, 0.25)
sizeTween:Play()
lastSizeTween = sizeTween
hatchingTweensJanitor:Add(sizeTween)
Expand All @@ -216,9 +217,6 @@ local function configureHatchUI(asyncResults, single: boolean, areaName: string)
end

function displayPurchaseResults(asyncResults, areaName: string, count: number, auto: boolean): ()
print(selectors.getStat(store:getState(), player.Name, "CurrentPetCount"))
print(selectors.getStat(store:getState(), player.Name, "MaxPetCount"))
print(count)
if
not asyncResults
or (selectors.getStat(store:getState(), player.Name, "CurrentPetCount") + count)
Expand Down Expand Up @@ -450,7 +448,13 @@ local function updateFoundsDisplay(foundPets): ()
continue
end

local petUI = player.PlayerGui:WaitForChild(petAreas[petName] .. "EggUI").Background.Pets[petName]
local eggUI = player.PlayerGui:FindFirstChild(petAreas[petName] .. "EggUI")

if not eggUI then
continue
end

local petUI = eggUI.Background.Pets[petName]
petUI.PetName.Text = petName
petUI.PetImage.ImageColor3 = Color3.fromRGB(255, 255, 255)
petUI.PetImage.ImageTransparency = 0
Expand Down
5 changes: 4 additions & 1 deletion src/client/UI/Inventories/PetInventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ function PetInventory:_initializeLockButton(petTemplate: ImageButton | any, lock
petTemplate.Lock.Visible = true
destructor:Add(
petTemplate.Lock.Activated:Connect(function()
if petTemplate.Equipped.Visible then
if
petTemplate.Equipped.Visible
or petUtils.getPet(petTemplate.PetName.Text):FindFirstChild "PermaLock"
then
return
end
petTemplate.Lock.Visible = false
Expand Down
11 changes: 11 additions & 0 deletions src/client/UI/Shops/RobuxShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ local mainUI = player.PlayerGui:WaitForChild "MainUI"

RobuxShop.Trigger = "RobuxShop"

local petProductIDs = ReplicatedStorage.Config.DevProductData.IDs

function RobuxShop:_closeFramesWithExclude(exclude)
for _, frame in self._ui.Background:GetChildren() do
if frame ~= exclude and self._ui:FindFirstChild(frame.Name:match "(%a+)Frame") then
Expand Down Expand Up @@ -98,6 +100,15 @@ function RobuxShop:_initialize(): ()
end)
end
end

for _, buttonDisplay in self._ui.Background.PetsFrame.PetsFrame:GetChildren() do
local productIDInstance = petProductIDs:FindFirstChild(buttonDisplay.Name)
if productIDInstance then
buttonDisplay.Purchase.Activated:Connect(function()
MarketplaceService:PromptProductPurchase(player, productIDInstance.Value)
end)
end
end
end

task.spawn(RobuxShop._initialize, RobuxShop)
Expand Down
13 changes: 12 additions & 1 deletion src/server/Combat/Perks/Pets.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local Players = game:GetService "Players"
local ReplicatedStorage = game:GetService "ReplicatedStorage"
local MarketplaceService = game:GetService "MarketplaceService"
local ServerScriptService = game:GetService "ServerScriptService"

local Remotes = require(ReplicatedStorage.Common.Remotes)
Expand All @@ -8,6 +9,8 @@ local actions = require(ServerScriptService.Server.State.Actions)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)

local devProductIDs = ReplicatedStorage.Config.DevProductData.IDs

local function evolvePet(player, petName)
local petOwnedCount = selectors.getPetOwnedCount(store:getState(), player.Name, petName)

Expand All @@ -31,7 +34,7 @@ local function evolvePet(player, petName)
store:dispatch(actions.unlockPlayerPets(player.Name, { [petName] = countToUnlock }))
end

store:dispatch(actions.deletePlayerPets(player.Name, { [petName] = 5 }))
store:dispatch(actions.deletePlayerPets(player.Name, { [petName] = 5 }, true))
store:dispatch(actions.givePlayerPets(player.Name, { ["Evolved " .. petName] = 1 }))

return 0
Expand Down Expand Up @@ -193,6 +196,14 @@ Remotes.Server:Get("EvolveAllPets"):Connect(function(player: Player)
return 0
end)

workspace.BuyGoldenDominus.Prompt.Triggered:Connect(function(player)
MarketplaceService:PromptProductPurchase(player, devProductIDs["1GoldenDominus"].Value)
end)

workspace.BuyReaper.Prompt.Triggered:Connect(function(player)
MarketplaceService:PromptProductPurchase(player, devProductIDs["1Reaper"].Value)
end)

store.changed:connect(function(newState, oldState)
for playerName, petInfo in newState.PetData do
if petInfo ~= oldState.PetData[playerName] then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ local ServerScriptService = game:GetService "ServerScriptService"
local store = require(ServerScriptService.Server.State.Store)
local actions = require(ServerScriptService.Server.State.Actions)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)
local regionUtils = require(ReplicatedStorage.Common.Utils.Player.RegionUtils)

local IDs = ReplicatedStorage.Config.DevProductData.IDs

local function awardPetsToPlayer(player: Player, petsDict: { [string]: number }): ()
store:dispatch(actions.givePlayerPets(player.Name, petsDict))
store:dispatch(actions.lockPlayerPets(player.Name, petsDict))

local petsToEquip, counter = {}, 0
local equippedPetsCount = petUtils.countPetsInDict(selectors.getEquippedPets(store:getState(), player.Name))
for _, petName in petUtils.getBestPetNames(petsDict, petUtils.countPetsInDict(petsDict)) do
if equippedPetsCount + counter >= selectors.getStat(store:getState(), player.Name, "MaxPetEquipCount") then
break
end
counter += 1
petsToEquip[petName] = if petsToEquip[petName] then petsToEquip[petName] + 1 else 1
end
if counter > 0 then
store:dispatch(actions.equipPlayerPets(player.Name, petsToEquip))
end
end

return {
[IDs.MissionSkip.Value] = function(player: Player)
local areaName = regionUtils.getPlayerLocationName(player.Name)
Expand All @@ -16,4 +35,16 @@ return {
store:dispatch(actions.completeMission(player.Name, areaName, gemReward, true))
store:dispatch(actions.incrementPlayerStat(player.Name, "Gems", gemReward))
end,
[IDs["1GoldenDominus"].Value] = function(player: Player)
awardPetsToPlayer(player, { ["Golden Dominus"] = 1 })
end,
[IDs["3GoldenDominus"].Value] = function(player: Player)
awardPetsToPlayer(player, { ["Golden Dominus"] = 3 })
end,
[IDs["1Reaper"].Value] = function(player: Player)
awardPetsToPlayer(player, { Reaper = 1 })
end,
[IDs["3Reaper"].Value] = function(player: Player)
awardPetsToPlayer(player, { Reaper = 3 })
end,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local rewarders = require(script.Rewarders)

return function(player: Player, productID: number): (boolean, string?)
if not rewarders[productID] then
return
return false, "No rewarder for product ID " .. tostring(productID)
end

return pcall(rewarders[productID], player)
Expand Down
3 changes: 2 additions & 1 deletion src/server/State/Actions/PetActions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ return {
end),
unlockPlayerPets = makeActionCreator(
"unlockPlayerPets",
function(playerName: string, petNames: { [string]: number })
function(playerName: string, petNames: { [string]: number }, force: boolean)
return {
playerName = playerName,
petsToUnlock = petNames,
force = force,
shouldSave = true,
}
end
Expand Down
4 changes: 4 additions & 0 deletions src/shared/State/Reducer/PetData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local ReplicatedStorage = game:GetService "ReplicatedStorage"
local Immut = require(ReplicatedStorage.Common.lib.Immut)
local Rodux = require(ReplicatedStorage.Common.lib.Rodux)
local Dict = require(ReplicatedStorage.Common.lib.Sift).Dictionary
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)
local defaultStates = require(ReplicatedStorage.Common.State.DefaultStates)

local produce = Immut.produce
Expand Down Expand Up @@ -71,6 +72,9 @@ return Rodux.createReducer({}, {
unlockPlayerPets = function(state, action)
return produce(state, function(draft)
for petName, quantity in action.petsToUnlock do
if petUtils.getPet(petName):FindFirstChild "PermaLock" and not action.force then
continue
end
draft[action.playerName].LockedPets[petName] -= quantity
if draft[action.playerName].LockedPets[petName] < 1 then
draft[action.playerName].LockedPets[petName] = nil
Expand Down
6 changes: 5 additions & 1 deletion src/shared/State/Reducer/Stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local defaultStates = require(ReplicatedStorage.Common.State.DefaultStates)
local rankUtils = require(ReplicatedStorage.Common.Utils.RankUtils)

local produce = Immut.produce
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)
local baseRequiredFear = game:GetService("ReplicatedStorage").Config.Workout.RequiredFear.Value

return Rodux.createReducer({}, {
Expand Down Expand Up @@ -61,7 +62,10 @@ return Rodux.createReducer({}, {
end,
givePlayerPets = function(state, action)
local addedPetCount = 0
for _, quantity in action.petsToGive do
for petName, quantity in action.petsToGive do
if petUtils.getPet(petName):FindFirstChild "PermaLock" then
continue
end
addedPetCount += quantity
end
return produce(state, function(draft)
Expand Down

0 comments on commit e51dba1

Please sign in to comment.