1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
package game
func (ctx *Context) getOwnerID(sID SpaceID) PlayerID {
for _, oP := range ctx.Properties.Owners {
if oP.SpaceID == sID {
return oP.OwnerID
}
}
return BankPlayerID
}
func (ctx *Context) ProcessChance() {
for {
visitorID, done := QueuePop(&ctx.Visitors.Chance)
if done {
break
}
card := ctx.Random.IntN(len(ChanceCards))
ctx.Turn.Log = append(ctx.Turn.Log, LogLandChance)
currentPos := ctx.Players.Alive[visitorID.Index()].CurrentSpaceID
switch card {
case 0:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, GetPlayerMoveDistance(currentPos, SpecialSpaces.StCharlesPlace))
case 1, 2:
for i := range BoardSpaces {
offset := int32(i)
next_pos := Add(currentPos, offset)
prop := BoardSpaces[next_pos.Index()]
if prop.PropertyType == TypeRailroad {
distance := GetPlayerMoveDistance(currentPos, next_pos)
if ctx.getOwnerID(CalculateNextPos(currentPos, distance)) != visitorID {
ctx.Turn.Modifier.RailroadRentMultiplier = 2
}
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, distance)
break
}
}
case 3:
for i := range BoardSpaces {
offset := int32(i)
next_pos := Add(currentPos, offset)
prop := BoardSpaces[next_pos.Index()]
if prop.PropertyType == TypeUtility {
distance := GetPlayerMoveDistance(currentPos, next_pos)
if ctx.getOwnerID(CalculateNextPos(currentPos, distance)) != visitorID {
ctx.Turn.Modifier.UtilityForceRentMultiplier = true
}
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, distance)
break
}
}
case 4:
ctx.PutPlayerInJail(visitorID)
case 5:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, GetPlayerMoveDistance(currentPos, SpecialSpaces.ReadingRailroad))
case 6:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, GetPlayerMoveDistance(currentPos, SpecialSpaces.Go))
case 7:
ctx.Players.Alive[ctx.Turn.Current.Index()].PardonCards++
case 8:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, GetPlayerMoveDistance(currentPos, SpecialSpaces.Boardwalk))
case 9:
ctx.AdjustPlayerMoney(visitorID, 150)
case 10:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, -3)
case 11:
ctx.AdjustPlayerMoney(visitorID, -15)
case 12:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, GetPlayerMoveDistance(currentPos, SpecialSpaces.IllinoisAvenue))
case 13:
var repairCost int32 = 0
for _, prop := range ctx.Properties.Owners {
ownerID := prop.OwnerID
spaceID := prop.SpaceID
space := BoardSpaces[spaceID.Index()]
if ownerID == visitorID && space.PropertyType == TypeColor {
colorID := space.SubIndexID
colorProp := ColorProperties[colorID]
if colorProp.Houses > ColorMaxHouses { // its a hotel
repairCost += 100
} else {
repairCost += colorProp.Houses * 25
}
}
}
ctx.AdjustPlayerMoney(visitorID, -repairCost)
case 14:
for i := range ctx.Players.Alive {
pID := PlayerID{ID: int32(i)}
if pID == visitorID {
ctx.AdjustPlayerMoney(pID, -50*int32(len(ctx.Players.Alive)-1))
} else {
ctx.AdjustPlayerMoney(pID, 50)
}
}
case 15:
ctx.AdjustPlayerMoney(visitorID, 50)
}
}
}
|