-
Notifications
You must be signed in to change notification settings - Fork 22
/
wheelOptions.go
98 lines (93 loc) · 3.58 KB
/
wheelOptions.go
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
package netobj
import (
"log"
"math/rand"
"strconv"
"github.com/fluofoxxo/outrun/config"
"github.com/fluofoxxo/outrun/consts"
"github.com/fluofoxxo/outrun/enums"
"github.com/fluofoxxo/outrun/obj"
"github.com/jinzhu/now"
)
type WheelOptions struct {
Items []string `json:"items"`
Item []int64 `json:"item"`
ItemWeight []int64 `json:"itemWeight"`
ItemWon int64 `json:"itemWon"`
NextFreeSpin int64 `json:"nextFreeSpin"` // midnight (start of next day)
SpinCost int64 `json:"spinCost"`
RouletteRank int64 `json:"rouletteRank"`
NumRouletteToken int64 `json:"numRouletteToken"`
NumJackpotRing int64 `json:"numJackpotRing"`
NumRemainingRoulette int64 `json:"numRemainingRoulette"`
ItemList []obj.Item `json:"itemList"`
}
func DefaultWheelOptions(numRouletteTicket, rouletteCountInPeriod int64) WheelOptions {
// TODO: Modifying this seems like a good way of figuring out what the game thinks each ID means in terms of items.
// const the below
// NOTE: Free spins occur when numRemainingRoulette > numRouletteToken
//items := []string{"200000", "120000", "120001", "120002", "200000", "900000", "120003", "120004"}
items := []string{strconv.Itoa(enums.IDTypeItemRouletteWin)} // first item is always jackpot/big/super
item := []int64{1}
for _ = range make([]byte, 7) { // loop 7 times
randomItem := consts.RandomItemListNormalWheel[rand.Intn(len(consts.RandomItemListNormalWheel))]
randomItemAmount := consts.NormalWheelItemAmountRange[randomItem].GetRandom()
items = append(items, randomItem)
item = append(item, randomItemAmount)
}
/*
item := []int64{1, 2, 2, 2, 1, 3, 2, 2}
*/
itemWeight := []int64{1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250}
//itemWon := int64(0)
itemWon := int64(rand.Intn(len(items)))
nextFreeSpin := now.EndOfDay().Unix() + 1 // midnight
spinCost := int64(87)
rouletteRank := int64(enums.WheelRankNormal)
//numRouletteToken := playerState.NumRouletteTicket
numRouletteToken := numRouletteTicket // The game uses the _current_ value, not as if it was in the past (This is hard to explain, maybe TODO: explain this better?)
numJackpotRing := int64(consts.RouletteJackpotRings)
// TODO: get rid of logic here!
numRemainingRoulette := numRouletteToken + consts.RouletteFreeSpins - rouletteCountInPeriod // TODO: is this proper?
if numRemainingRoulette < numRouletteToken {
numRemainingRoulette = numRouletteToken
}
itemList := []obj.Item{}
out := WheelOptions{
items,
item,
itemWeight,
itemWon,
nextFreeSpin,
spinCost,
rouletteRank,
numRouletteToken,
numJackpotRing,
numRemainingRoulette,
itemList,
}
return out
}
func UpgradeWheelOptions(origWheel WheelOptions, numRouletteTicket, rouletteCountInPeriod int64) WheelOptions {
newWheel := DefaultWheelOptions(numRouletteTicket, rouletteCountInPeriod)
newWheel.RouletteRank = origWheel.RouletteRank
if origWheel.Items[origWheel.ItemWon] == strconv.Itoa(enums.IDTypeItemRouletteWin) { // if landed on big/super or jackpot
landedOnUpgrade := origWheel.RouletteRank == enums.WheelRankNormal || origWheel.RouletteRank == enums.WheelRankBig
if config.CFile.DebugPrints {
log.Printf("%v\n", origWheel.RouletteRank)
log.Printf("%v\n", landedOnUpgrade)
}
if landedOnUpgrade {
if config.CFile.DebugPrints {
log.Println("landedOnUpgrade")
}
newWheel.RouletteRank++ // increase the rank
} else {
if config.CFile.DebugPrints {
log.Println("NOT landedOnUpgrade")
}
newWheel.RouletteRank = enums.WheelRankNormal
}
}
return newWheel
}