]> Skullheadx's Git Forge - monopoly-web.git/commitdiff
utility
authorSkullheadx <admonty1@protonmail.com>
Sun, 17 May 2026 03:44:49 +0000 (23:44 -0400)
committerSkullheadx <admonty1@protonmail.com>
Sun, 17 May 2026 03:44:49 +0000 (23:44 -0400)
game/color.go
game/game.go
game/utility.go [new file with mode: 0644]

index 13547827e4194b905a3ac5816e4b6d66acbbb5e1..55c3ed41b731c69fd1dff62da31d14c54d6d895e 100644 (file)
@@ -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]
index b137ba9d0a5bf3685a1631ec0726b3f987cff789..7c6cfc869538743cb134c94838af16412350d21f 100644 (file)
@@ -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 (file)
index 0000000..292a7d2
--- /dev/null
@@ -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)
+       }
+}