Fix shop action costs and pass semantics.
Only buying costs gold; selling and trading (Triple) are free. Pass is now a final action, legal only at or under the pet limit: it forfeits remaining gold and ends that player's shopping for the round, with the shop closing once everyone has passed. That makes the separate cleanup phase unreachable (you sell down in-shop before passing), so it is removed. The client asks for confirmation before passing, and the bot knows buys are the only coin sink, when passing is legal, and that it must sell down before it can pass.
This commit is contained in:
+11
-15
@@ -76,8 +76,6 @@ func botDelay(phase game.Phase) time.Duration {
|
||||
switch phase {
|
||||
case game.PhaseShop:
|
||||
return ms(700, 900)
|
||||
case game.PhaseCleanup:
|
||||
return ms(900, 600)
|
||||
case game.PhaseArrange:
|
||||
return ms(1600, 1600)
|
||||
default: // battle acknowledgement
|
||||
@@ -127,9 +125,6 @@ func applyBotAction(g *game.Game, playerID string, a *ai.Action) error {
|
||||
case "buy":
|
||||
return g.Buy(playerID, a.Row)
|
||||
case "sell":
|
||||
if g.Phase == game.PhaseCleanup {
|
||||
return g.CleanupSell(playerID, a.Cards)
|
||||
}
|
||||
return g.Sell(playerID, a.Cards)
|
||||
case "trade":
|
||||
return g.TradeStart(playerID, a.Cards)
|
||||
@@ -146,8 +141,9 @@ func applyBotAction(g *game.Game, playerID string, a *ai.Action) error {
|
||||
}
|
||||
|
||||
// botFallback makes the trivially legal move for whatever the game is
|
||||
// waiting on: pass the shop turn, take the first trade option, sell the
|
||||
// first excess pets, submit the deck as-is, or acknowledge the battle.
|
||||
// waiting on: pass the shop turn (selling down to the pet limit first if
|
||||
// passing would be refused), take the first trade option, submit the deck
|
||||
// as-is, or acknowledge the battle.
|
||||
func botFallback(g *game.Game, playerID string) error {
|
||||
p := g.PlayerByID(playerID)
|
||||
if p == nil {
|
||||
@@ -158,16 +154,16 @@ func botFallback(g *game.Game, playerID string) error {
|
||||
if g.Pending != nil && g.Pending.PlayerID == playerID {
|
||||
return g.TradeChoose(playerID, 0)
|
||||
}
|
||||
return g.Pass(playerID)
|
||||
case game.PhaseCleanup:
|
||||
excess := p.PetCount() - game.MaxPets
|
||||
ids := make([]string, 0, excess)
|
||||
for _, c := range p.Deck {
|
||||
if c.IsPet() && len(ids) < excess {
|
||||
ids = append(ids, c.ID)
|
||||
if excess := p.PetCount() - game.MaxPets; excess > 0 {
|
||||
ids := make([]string, 0, excess)
|
||||
for _, c := range p.Deck {
|
||||
if c.IsPet() && len(ids) < excess {
|
||||
ids = append(ids, c.ID)
|
||||
}
|
||||
}
|
||||
return g.Sell(playerID, ids)
|
||||
}
|
||||
return g.CleanupSell(playerID, ids)
|
||||
return g.Pass(playerID)
|
||||
case game.PhaseArrange:
|
||||
ids := make([]string, len(p.Deck))
|
||||
for i, c := range p.Deck {
|
||||
|
||||
Reference in New Issue
Block a user