Added time limited bankrupcy, steroids for benching (don't persist across restarts), removed aliases from command list, ping, strongest, don't allow vlk to roll.
This commit is contained in:
parent
ca91956e27
commit
d4c4e38ba8
@ -89,6 +89,7 @@ const (
|
|||||||
Action_Rest ActionType = 2
|
Action_Rest ActionType = 2
|
||||||
Action_Lift ActionType = 3
|
Action_Lift ActionType = 3
|
||||||
Action_Riot ActionType = 4
|
Action_Riot ActionType = 4
|
||||||
|
Action_Bankrupt ActionType = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
type ActionType int
|
type ActionType int
|
||||||
@ -109,6 +110,12 @@ func (w *WatDb) Act(player *Player, actionType ActionType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *WatDb) Strongest() []Player {
|
||||||
|
var user = make([]Player, 10)
|
||||||
|
w.db.Limit(10).Order("anarchy desc").Find(&user)
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
|
||||||
func (w *WatDb) TopLost() []Player {
|
func (w *WatDb) TopLost() []Player {
|
||||||
var user = make([]Player, 10)
|
var user = make([]Player, 10)
|
||||||
w.db.Limit(10).Order("coins_lost desc").Find(&user)
|
w.db.Limit(10).Order("coins_lost desc").Find(&user)
|
||||||
|
69
wat/game.go
69
wat/game.go
@ -16,7 +16,9 @@ type WatGame struct {
|
|||||||
db *WatDb
|
db *WatDb
|
||||||
me Player
|
me Player
|
||||||
commands map[string](func(*Player, []string) string)
|
commands map[string](func(*Player, []string) string)
|
||||||
|
aliases map[string](func(*Player, []string) string)
|
||||||
lifeCommands map[string](func(*Player, []string) string)
|
lifeCommands map[string](func(*Player, []string) string)
|
||||||
|
roid map[string]int
|
||||||
}
|
}
|
||||||
|
|
||||||
var currency = "watcoin"
|
var currency = "watcoin"
|
||||||
@ -24,19 +26,24 @@ var currencys = "watcoins"
|
|||||||
var unconscious = "wat, your hands fumble and fail you. try resting, weakling."
|
var unconscious = "wat, your hands fumble and fail you. try resting, weakling."
|
||||||
|
|
||||||
func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
|
func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
|
||||||
g := WatGame{bot, db, Player{}, nil, nil}
|
g := WatGame{bot, db, Player{}, nil, nil, nil, map[string]int{}}
|
||||||
g.me = g.db.User(bot.Nick, "tripsit/user/"+bot.Nick, true)
|
g.me = g.db.User(bot.Nick, "tripsit/user/"+bot.Nick, true)
|
||||||
g.commands = map[string](func(*Player, []string) string){
|
g.commands = map[string](func(*Player, []string) string){
|
||||||
//"wat": g.megaWat,
|
//"wat": g.megaWat,
|
||||||
|
"steroid": g.Steroid,
|
||||||
"watch": g.Watch,
|
"watch": g.Watch,
|
||||||
"coins": g.Balance,
|
"coins": g.Balance,
|
||||||
"send": g.Send,
|
"send": g.Send,
|
||||||
"rest": g.Rest,
|
"rest": g.Rest,
|
||||||
"leech": g.Leech,
|
"leech": g.Leech,
|
||||||
"roll": g.Roll,
|
"roll": g.Roll,
|
||||||
"flip": g.Roll,
|
|
||||||
"dice": g.Dice,
|
"dice": g.Dice,
|
||||||
"mine": g.Mine,
|
"mine": g.Mine,
|
||||||
|
"bankrupt": g.Bankrupt,
|
||||||
|
}
|
||||||
|
g.aliases = map[string](func(*Player, []string) string){
|
||||||
|
"sleep": g.Rest,
|
||||||
|
"flip": g.Roll,
|
||||||
}
|
}
|
||||||
g.lifeCommands = map[string](func(*Player, []string) string){
|
g.lifeCommands = map[string](func(*Player, []string) string){
|
||||||
"riot": g.Riot,
|
"riot": g.Riot,
|
||||||
@ -54,11 +61,17 @@ func (g *WatGame) Msg(m *irc.Message, player *Player, fields []string) {
|
|||||||
reply := ""
|
reply := ""
|
||||||
if g.commands[command] != nil {
|
if g.commands[command] != nil {
|
||||||
reply = g.commands[command](player, fields)
|
reply = g.commands[command](player, fields)
|
||||||
|
} else if g.aliases[command] != nil {
|
||||||
|
reply = g.aliases[command](player, fields)
|
||||||
} else {
|
} else {
|
||||||
// one liners
|
// one liners
|
||||||
switch strings.ToLower(command) {
|
switch strings.ToLower(command) {
|
||||||
|
case "ping":
|
||||||
|
reply = ",beef"
|
||||||
case "help":
|
case "help":
|
||||||
reply = g.help()
|
reply = g.help()
|
||||||
|
case "strongest":
|
||||||
|
reply = fmt.Sprintf("stronk: %s", g.Strongest())
|
||||||
case "toplost":
|
case "toplost":
|
||||||
reply = fmt.Sprintf("%s losers: %s", currency, g.TopLost())
|
reply = fmt.Sprintf("%s losers: %s", currency, g.TopLost())
|
||||||
case "topten":
|
case "topten":
|
||||||
@ -166,6 +179,9 @@ func (g *WatGame) Roll(player *Player, fields []string) string {
|
|||||||
if len(fields) < 2 {
|
if len(fields) < 2 {
|
||||||
return fmt.Sprintf("roll <%s> pls - u must score < 50 if u want 2 win", currency)
|
return fmt.Sprintf("roll <%s> pls - u must score < 50 if u want 2 win", currency)
|
||||||
}
|
}
|
||||||
|
if player.Nick == "vlk" {
|
||||||
|
return "you've had enough rolling friend. unroll it."
|
||||||
|
}
|
||||||
amount, e := g.Int(fields[1])
|
amount, e := g.Int(fields[1])
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return e.Error()
|
return e.Error()
|
||||||
@ -191,6 +207,21 @@ func (g *WatGame) Roll(player *Player, fields []string) string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *WatGame) Bankrupt(player *Player, fields []string) string {
|
||||||
|
if player.Coins > 10 {
|
||||||
|
return fmt.Sprintf("hmm, with %d %s, you're too rich. go get poor.", player.Coins, currency)
|
||||||
|
}
|
||||||
|
minTime := int64(14400)
|
||||||
|
if !g.CanAct(player, Action_Bankrupt, minTime) {
|
||||||
|
return "pity is only valid once every 4 hours"
|
||||||
|
}
|
||||||
|
player.Coins += 50
|
||||||
|
player.Bankrupcy += 1
|
||||||
|
g.db.Act(player, Action_Bankrupt)
|
||||||
|
g.db.Update(player)
|
||||||
|
return fmt.Sprintf("here's some pity money. you've been bankrupt %d times.", player.Bankrupcy)
|
||||||
|
}
|
||||||
|
|
||||||
func (g *WatGame) Punch(player *Player, fields []string) string {
|
func (g *WatGame) Punch(player *Player, fields []string) string {
|
||||||
if len(fields) < 2 {
|
if len(fields) < 2 {
|
||||||
return "punch <target> pls"
|
return "punch <target> pls"
|
||||||
@ -373,7 +404,7 @@ func (g *WatGame) CanAct(player *Player, action ActionType, minTime int64) bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *WatGame) Bench(player *Player, fields []string) string {
|
func (g *WatGame) Bench(player *Player, fields []string) string {
|
||||||
minTime := int64(2400)
|
minTime := int64(115200)
|
||||||
if !g.CanAct(player, Action_Lift, minTime) {
|
if !g.CanAct(player, Action_Lift, minTime) {
|
||||||
return "you're tired. no more lifting for now."
|
return "you're tired. no more lifting for now."
|
||||||
}
|
}
|
||||||
@ -392,6 +423,20 @@ func (g *WatGame) Bench(player *Player, fields []string) string {
|
|||||||
value = 10
|
value = 10
|
||||||
reply += "four twenty blaze it bro! "
|
reply += "four twenty blaze it bro! "
|
||||||
}
|
}
|
||||||
|
if g.roid[player.Nick] != 0 {
|
||||||
|
delete(g.roid, player.Nick)
|
||||||
|
success := g.RandInt(2)
|
||||||
|
if success != 0 {
|
||||||
|
player.Health = 0
|
||||||
|
player.Anarchy -= 10
|
||||||
|
g.db.Act(player, Action_Lift)
|
||||||
|
g.db.Update(player)
|
||||||
|
return fmt.Sprintf("%s tried to lift %d but halfway through their %d reps, their heart literally exploded from steroid use. They are now unconscious.", player.Nick, weight, reps)
|
||||||
|
} else {
|
||||||
|
reply += fmt.Sprintf("roid rage increased the effectiveness! ")
|
||||||
|
value *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
g.db.Act(player, Action_Lift)
|
g.db.Act(player, Action_Lift)
|
||||||
player.Anarchy += value
|
player.Anarchy += value
|
||||||
g.db.Update(player)
|
g.db.Update(player)
|
||||||
@ -467,6 +512,14 @@ func (g *WatGame) Mine(player *Player, _ []string) string {
|
|||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *WatGame) Steroid(player *Player, fields []string) string {
|
||||||
|
if g.roid[player.Nick] != 0 {
|
||||||
|
return "Taking more than the recommended amount of steroids is, well, not recommended."
|
||||||
|
}
|
||||||
|
g.roid[player.Nick] = 1
|
||||||
|
return fmt.Sprintf("%s has eaten anabolic steroids. While they're good for building strength, it's dangerous to lift heavy weights. I hope you know what you're doing...", player.Nick)
|
||||||
|
}
|
||||||
|
|
||||||
func (g *WatGame) Watch(player *Player, fields []string) string {
|
func (g *WatGame) Watch(player *Player, fields []string) string {
|
||||||
if len(fields) > 1 {
|
if len(fields) > 1 {
|
||||||
maybePlayer, err := g.GetTarget("", fields[1])
|
maybePlayer, err := g.GetTarget("", fields[1])
|
||||||
@ -491,6 +544,15 @@ func (g *WatGame) Balance(player *Player, fields []string) string {
|
|||||||
return fmt.Sprintf(balStr, balPlayer.Nick, currency, balPlayer.Coins, time.Now().Unix()-balPlayer.LastMined, balPlayer.CoinsLost)
|
return fmt.Sprintf(balStr, balPlayer.Nick, currency, balPlayer.Coins, time.Now().Unix()-balPlayer.LastMined, balPlayer.CoinsLost)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *WatGame) Strongest() string {
|
||||||
|
players := g.db.Strongest()
|
||||||
|
ret := ""
|
||||||
|
for _, p := range players {
|
||||||
|
ret += PrintTwo(p.Nick, uint64(p.Anarchy))
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func (g *WatGame) TopLost() string {
|
func (g *WatGame) TopLost() string {
|
||||||
players := g.db.TopLost()
|
players := g.db.TopLost()
|
||||||
ret := ""
|
ret := ""
|
||||||
@ -499,6 +561,7 @@ func (g *WatGame) TopLost() string {
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *WatGame) TopTen() string {
|
func (g *WatGame) TopTen() string {
|
||||||
players := g.db.TopTen()
|
players := g.db.TopTen()
|
||||||
ret := ""
|
ret := ""
|
||||||
|
Loading…
Reference in New Issue
Block a user