]> Skullheadx's Git Forge - monopoly-web.git/commitdiff
chest
authorSkullheadx <admonty1@protonmail.com>
Sun, 17 May 2026 07:03:57 +0000 (03:03 -0400)
committerSkullheadx <admonty1@protonmail.com>
Sun, 17 May 2026 07:06:26 +0000 (03:06 -0400)
game/chance.go
game/chest.go [new file with mode: 0644]
game/game.go
game/movement.go

index 0d89f174da287b8f8b50ca53fffab4a25c582187..c1cd5560a187c9084b8c9f862f9b948eb371c9ea 100644 (file)
@@ -19,7 +19,7 @@ var ChanceCards = [...]string{
        15: "Bank pays you dividend of $50.",
 }
 
-func getPlayerMoveDistance(start int32, dest int32) int32 {
+func GetPlayerMoveDistance(start int32, dest int32) int32 {
        distance := dest - start
        if distance < 0 {
                distance += int32(len(BoardSpaces))
@@ -35,14 +35,14 @@ func ProcessChance() {
 
                switch card {
                case 0:
-                       MoveQueue = append(MoveQueue, getPlayerMoveDistance(currentPos, StCharlesPlaceSpaceID))
+                       MoveQueue = append(MoveQueue, GetPlayerMoveDistance(currentPos, StCharlesPlaceSpaceID))
                case 1, 2:
                        for i := range BoardSpaces {
                                offset := int32(i)
                                next_pos := currentPos + offset
                                propertyType := BoardSpaces[next_pos]
                                if propertyType == TypeRailroad {
-                                       distance := getPlayerMoveDistance(currentPos, next_pos)
+                                       distance := GetPlayerMoveDistance(currentPos, next_pos)
                                        if PropertyOwners[SpaceToOwnableProperty[CalculateNextPos(currentPos, distance)]] != visitorID {
                                                ModifierRailroadRentMultiplier = 2
                                        }
@@ -55,7 +55,7 @@ func ProcessChance() {
                                next_pos := currentPos + offset
                                propertyType := BoardSpaces[next_pos]
                                if propertyType == TypeUtility {
-                                       distance := getPlayerMoveDistance(currentPos, next_pos)
+                                       distance := GetPlayerMoveDistance(currentPos, next_pos)
                                        if PropertyOwners[SpaceToOwnableProperty[CalculateNextPos(currentPos, distance)]] != visitorID {
                                                ModifierUtilityForceRentMultiplier = true
                                        }
@@ -66,13 +66,13 @@ func ProcessChance() {
                case 4:
                // TODO: GO TO JAIL
                case 5:
-                       MoveQueue = append(MoveQueue, getPlayerMoveDistance(currentPos, ReadingRailroadSpaceID))
+                       MoveQueue = append(MoveQueue, GetPlayerMoveDistance(currentPos, ReadingRailroadSpaceID))
                case 6:
-                       MoveQueue = append(MoveQueue, getPlayerMoveDistance(currentPos, GoSpaceID))
+                       MoveQueue = append(MoveQueue, GetPlayerMoveDistance(currentPos, GoSpaceID))
                case 7:
                // TODO: GET OUT OF JAIL FREE
                case 8:
-                       MoveQueue = append(MoveQueue, getPlayerMoveDistance(currentPos, BoardwalkSpaceID))
+                       MoveQueue = append(MoveQueue, GetPlayerMoveDistance(currentPos, BoardwalkSpaceID))
                case 9:
                        AdjustPlayerMoney(visitorID, 150)
                case 10:
@@ -80,6 +80,8 @@ func ProcessChance() {
                case 11:
                        AdjustPlayerMoney(visitorID, -15)
                case 12:
+                       MoveQueue = append(MoveQueue, GetPlayerMoveDistance(currentPos, IllinoisAvenueSpaceID))
+               case 13:
                        var repairCost int32 = 0
                        for propID, ownerID := range PropertyOwners {
                                if ownerID == visitorID && OwnablePropertyType[propID] == TypeColor {
diff --git a/game/chest.go b/game/chest.go
new file mode 100644 (file)
index 0000000..af69211
--- /dev/null
@@ -0,0 +1,84 @@
+package game
+
+var ChestCards = [...]string{
+       0:  "Advance to Go. (Collect $200)",
+       1:  "Bank error in your favor. Collect $200.",
+       2:  "Holiday fund matures. Receive $100.",
+       3:  "Life insurance matures. Collect $100.",
+       4:  "You inherit $100.",
+       5:  "From sale of stock you get $50.",
+       6:  "Income tax refund. Collect $20.",
+       7:  "It is your birthday. Collect $10 from every player.",
+       8:  "You are assessed for street repair. $40 per house. $115 per hotel.",
+       9:  "Pay hospital fees of $100.",
+       10: "Pay school fees of $50.",
+       11: "Doctor’s fee. Pay $50.",
+       12: "Receive $25 consultancy fee.",
+       13: "Get Out of Jail Free.",
+       14: "Go to Jail. Go directly to jail, do not pass Go, do not collect $200.",
+       15: "You have won second prize in a beauty contest. Collect $10.",
+}
+
+func ProcessChest() {
+       for _, visitorID := range ChestVisitors {
+               card := RandSrc.IntN(len(ChanceCards))
+
+               currentPos := Users[visitorID].CurrentSpaceID
+
+               switch card {
+               case 0:
+                       MoveQueue = append(MoveQueue, GetPlayerMoveDistance(currentPos, GoSpaceID))
+               case 1:
+                       AdjustPlayerMoney(visitorID, 200)
+               case 2:
+                       AdjustPlayerMoney(visitorID, 100)
+               case 3:
+                       AdjustPlayerMoney(visitorID, 100)
+               case 4:
+                       AdjustPlayerMoney(visitorID, 100)
+               case 5:
+                       AdjustPlayerMoney(visitorID, 50)
+               case 6:
+                       AdjustPlayerMoney(visitorID, 20)
+               case 7:
+                       for i := range Users {
+                               pID := int32(i)
+                               if pID == visitorID {
+                                       AdjustPlayerMoney(pID, 10*int32(len(Users)-1))
+                               } else {
+                                       AdjustPlayerMoney(pID, -10)
+                               }
+
+                       }
+               case 8:
+                       var repairCost int32 = 0
+                       for propID, ownerID := range PropertyOwners {
+                               if ownerID == visitorID && OwnablePropertyType[propID] == TypeColor {
+                                       colorID := OwnableToRespProperty[int32(propID)]
+                                       colorProp := ColorProperties[colorID]
+                                       if colorProp.Houses > MAX_PROP_HOUSES { // its a hotel
+                                               repairCost += 100
+                                       } else {
+                                               repairCost += colorProp.Houses * 25
+                                       }
+                               }
+                       }
+
+                       AdjustPlayerMoney(visitorID, -repairCost)
+               case 9:
+                       AdjustPlayerMoney(visitorID, -100)
+               case 10:
+                       MoveQueue = append(MoveQueue, -50)
+               case 11:
+                       AdjustPlayerMoney(visitorID, -50)
+               case 12:
+                       AdjustPlayerMoney(visitorID, 25)
+               case 13:
+               // TODO: GO TO JAIL
+               case 14:
+                       // TODO: GET OUT OF JAIL FREE
+               case 15:
+                       AdjustPlayerMoney(visitorID, 10)
+               }
+       }
+}
index b3b35fba71a07f45ed229d2364fecd98efa7ead1..ac33da8e4219bbf9c7131c322bda4e2cf5841dc5 100644 (file)
@@ -70,7 +70,7 @@ func RollDice() {
                ProcessOwnedRailroad()
 
                ProcessChance()
-               // ProcessChest()
+               ProcessChest()
 
                // ProcessPolice()
                // ProcessJail()
index 40a9f5d786aba3a4df596404b3adaa9f793ac51c..01d2323f9e5388f87649331c57e19013beba2abf 100644 (file)
@@ -187,6 +187,7 @@ var StCharlesPlaceSpaceID int32 = 0
 var GoSpaceID int32 = 0
 var ReadingRailroadSpaceID int32 = 0
 var BoardwalkSpaceID int32 = 0
+var IllinoisAvenueSpaceID int32 = 0
 
 func init() {
        var (
@@ -212,10 +213,13 @@ func init() {
                        OwnableToRespProperty[ownableIndex] = colorIndex
                        RespPropertyToOwnable[colorIndex] = ownableIndex
 
-                       if ColorProperties[colorIndex].Name == "St. Charles Place" {
+                       switch ColorProperties[colorIndex].Name {
+                       case "St. Charles Place":
                                StCharlesPlaceSpaceID = spaceID
-                       } else if ColorProperties[colorIndex].Name == "Boardwalk" {
+                       case "Boardwalk":
                                BoardwalkSpaceID = spaceID
+                       case "Illinois Avenue":
+                               IllinoisAvenueSpaceID = spaceID
                        }
 
                        colorIndex++