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
|
package game
func (ctx *Context) ProcessChest() {
for {
visitorID, done := QueuePop(&ctx.Visitors.Chest)
if done {
break
}
card := ctx.Random.IntN(len(ChanceCards))
ctx.Turn.Log = append(ctx.Turn.Log, LogLandChest)
currentPos := ctx.Players.Alive[visitorID.Index()].CurrentSpaceID
switch card {
case 0:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, GetPlayerMoveDistance(currentPos, SpecialSpaces.Go))
case 1:
ctx.AdjustPlayerMoney(visitorID, 200)
case 2:
ctx.AdjustPlayerMoney(visitorID, 100)
case 3:
ctx.AdjustPlayerMoney(visitorID, 100)
case 4:
ctx.AdjustPlayerMoney(visitorID, 100)
case 5:
ctx.AdjustPlayerMoney(visitorID, 50)
case 6:
ctx.AdjustPlayerMoney(visitorID, 20)
case 7:
for i := range ctx.Players.Alive {
pID := PlayerID{ID: int32(i)}
if pID == visitorID {
ctx.AdjustPlayerMoney(pID, 10*int32(len(ctx.Players.Alive)-1))
} else {
ctx.AdjustPlayerMoney(pID, -10)
}
}
case 8:
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 9:
ctx.AdjustPlayerMoney(visitorID, -100)
case 10:
ctx.Turn.MoveQueue = append(ctx.Turn.MoveQueue, -50)
case 11:
ctx.AdjustPlayerMoney(visitorID, -50)
case 12:
ctx.AdjustPlayerMoney(visitorID, 25)
case 13:
ctx.PutPlayerInJail(visitorID)
case 14:
ctx.Players.Alive[ctx.Turn.Current.Index()].PardonCards++
case 15:
ctx.AdjustPlayerMoney(visitorID, 10)
}
}
}
|