Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/apps/game/src/components/provider/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class GameProvider {
method: "subscribe",
id: "0",
params: {
query: `${eventGame}.${attributeGameID}='${id.toString()}'`
id: id.toString()
}
}))
console.log("subscribed to game " + id.toString())
Expand Down Expand Up @@ -297,4 +297,4 @@ export class GameMsgClient implements IGameMsgClient {
// throw new Error(resp.rawLog)
// return MsgChangeParamsResponse.decode(new _m0.Reader(resp.data[0]!.data))
}
}
}
13 changes: 7 additions & 6 deletions x/game/types/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,15 @@ func (g *Game) Move(player string, populace uint32, direction Direction, amount
fmt.Sprintf("%d >= %d", int(populace), len(faction.Population)))
}

pop := faction.Population[int(populace)]


// Validate that the player's populace has not already acted
if faction.Population[populace].Used {
if pop.Used {
return sdkerrors.Wrap(ErrPopulaceAlreadActed,
fmt.Sprintf("step=%d, populace=%d", g.State.Step, populace))
}

pop := faction.Population[int(populace)]

// Validate that the amount to move is less than or equal to total
// population
Expand All @@ -175,12 +177,11 @@ func (g *Game) Move(player string, populace uint32, direction Direction, amount
// abandoning a settlement with the exception of a capital which
// must always be occupied (in conflicts over a capital, there can
// never be a draw)
if pop.Amount == amount && pop.Settlement == Settlement_CAPITAL {
return sdkerrors.Wrap(ErrAbandoningCapital, pop.Position.String())
if pop.Amount <= amount {
amount = pop.Amount - 1
}
Comment on lines +180 to 182
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you trying to make it that you always leave behind one population? I was thinking of making that change just in the UI. Like you press a hotkey and a move button and it moves all your population but 1. Actually Noam suggested that


// All validity checks have passed. Now we update state.

newIndex := g.Map.GetNeighbor(index, direction)
territory, ok := g.Territory[newIndex]
newPos := g.Map.GetPosition(newIndex)
Expand Down Expand Up @@ -267,7 +268,7 @@ func (g *Game) Move(player string, populace uint32, direction Direction, amount

} else {
// The player is marching into new unchartered territory
if amount == pop.Amount { // with the entire population
if amount == pop.Amount { // with the entire population // this is never happening now, should we remove?
pop.Position = newPos
g.Territory[newIndex] = g.Territory[index].Copy()
delete(g.Territory, index)
Expand Down