From: Skullheadx Date: Sun, 17 May 2026 03:44:49 +0000 (-0400) Subject: utility X-Git-Url: http://git.skullheadx.com/index.css?a=commitdiff_plain;h=67832986ef5229631d53f770caf4939062f9df8b;p=monopoly-web.git utility --- diff --git a/game/color.go b/game/color.go index 1354782..55c3ed4 100644 --- a/game/color.go +++ b/game/color.go @@ -1,10 +1,10 @@ package game func processOwnedColors() { - for _, ocv := range OwnedColorVisitors { - visitorID := ocv.visitorID - ownerID := ocv.ownerID - colorID := ocv.colorID + for _, oCV := range OwnedColorVisitors { + visitorID := oCV.visitorID + ownerID := oCV.ownerID + colorID := oCV.colorID prop := ColorProperties[colorID] prices := ColorPropertyRents[colorID] diff --git a/game/game.go b/game/game.go index b137ba9..7c6cfc8 100644 --- a/game/game.go +++ b/game/game.go @@ -3,7 +3,7 @@ package game var Users []User var DebtEvents []int32 -func HasMonopoly(playerID int32, targetGroup ColorGroup) bool { +func HasColorMonopoly(playerID int32, targetGroup ColorGroup) bool { var ownedCount int32 for colorID, ownerID := range PropertyOwners { if ownerID == playerID && ColorProperties[colorID].GroupID == targetGroup { @@ -14,6 +14,17 @@ func HasMonopoly(playerID int32, targetGroup ColorGroup) bool { return ownedCount == ColorGroupSizes[targetGroup] } +func HasUtiltyMonopoly(playerID int32) bool { + var ownedCount int32 + for _, ownerID := range PropertyOwners { + if ownerID == playerID { + ownedCount++ + } + } + + return ownedCount == int32(len(UtilityProperties)) +} + func IsInDebt(playerID int32) (bool, int32) { for i, pID := range DebtEvents { if pID == playerID { diff --git a/game/utility.go b/game/utility.go new file mode 100644 index 0000000..292a7d2 --- /dev/null +++ b/game/utility.go @@ -0,0 +1,15 @@ +package game + +func processOwnedUtility() { + for _, oUV := range OwnedUtilityVisitors { + visitorID := oUV.visitorID + ownerID := oUV.ownerID + // utilityID := oUV.utilityID + diceRoll := oUV.diceRoll + + var rent int32 = UtilityRentMult[HasUtiltyMonopoly(ownerID)] * diceRoll + + AdjustPlayerMoney(visitorID, -rent) + AdjustPlayerMoney(ownerID, rent) + } +}