本文整理汇总了Golang中github.com/svera/acquire/interfaces.Tile类的典型用法代码示例。如果您正苦于以下问题:Golang Tile类的具体用法?Golang Tile怎么用?Golang Tile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tile类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: HasTile
// HasTile checks if the passed tile is in player's hand
func (p *Player) HasTile(tile interfaces.Tile) bool {
for _, currentTile := range p.tiles {
if currentTile.Number() == tile.Number() && currentTile.Letter() == tile.Letter() {
return true
}
}
return false
}
示例2: DiscardTile
// DiscardTile removes passed tile from the tileset
func (t *Tileset) DiscardTile(tl interfaces.Tile) {
for i, currentTile := range t.tiles {
if currentTile.Number() == tl.Number() && currentTile.Letter() == tl.Letter() {
t.tiles = append(t.tiles[:i], t.tiles[i+1:]...)
break
}
}
}
示例3: TileMergeCorporations
// TileMergeCorporations checks if the passed tile merges two or more corporations, returns a map of
// corporations categorized between "acquirer" and "defunct"
func (b *Board) TileMergeCorporations(t interfaces.Tile) (bool, map[string][]interfaces.Corporation) {
corporations := b.AdjacentCorporations(t.Number(), t.Letter())
if len(corporations) > 1 {
return true, categorizeMerge(corporations)
}
return false, map[string][]interfaces.Corporation{}
}
示例4: DiscardTile
// DiscardTile discards the passed tile from player's hand
func (p *Player) DiscardTile(tile interfaces.Tile) interfaces.Player {
for i, currentTile := range p.tiles {
if currentTile.Number() == tile.Number() && currentTile.Letter() == tile.Letter() {
p.tiles = append(p.tiles[:i], p.tiles[i+1:]...)
return p
}
}
return p
}
示例5: isTilePermanentlyUnplayable
// Returns true if a tile is permanently unplayable, that is,
// that putting it on the board would merge two or more safe corporations
func (g *Game) isTilePermanentlyUnplayable(tl interfaces.Tile) bool {
adjacents := g.board.AdjacentCorporations(tl.Number(), tl.Letter())
safeNeighbours := 0
for _, adjacent := range adjacents {
if adjacent.IsSafe() {
safeNeighbours++
}
if safeNeighbours == 2 {
return true
}
}
return false
}
示例6: TileFoundCorporation
// TileFoundCorporation checks if the passed tile founds a new corporation, returns a slice of tiles
// composing this corporation
func (b *Board) TileFoundCorporation(t interfaces.Tile) (bool, []interfaces.Tile) {
var newCorporationTiles []interfaces.Tile
adjacent := b.adjacentTiles(t.Number(), t.Letter())
for _, adjacentTile := range adjacent {
if adjacentTile.Type() == interfaces.CorporationOwner {
return false, []interfaces.Tile{}
}
newCorporationTiles = append(newCorporationTiles, adjacentTile.(interfaces.Tile))
}
if len(newCorporationTiles) > 0 {
newCorporationTiles = append(newCorporationTiles, t)
return true, newCorporationTiles
}
return false, newCorporationTiles
}
示例7: isTileTemporarilyUnplayable
// Returns true if a tile is temporarily unplayable, that is,
// that putting it on the board would create an 8th corporation
func (g *Game) isTileTemporarilyUnplayable(tl interfaces.Tile) bool {
if len(g.activeCorporations()) < totalCorporations {
return false
}
adjacents := g.board.AdjacentCells(tl.Number(), tl.Letter())
emptyAdjacentCells := 0
for _, adjacent := range adjacents {
if adjacent.Type() == interfaces.CorporationOwner {
return false
}
if adjacent.Type() == interfaces.EmptyOwner {
emptyAdjacentCells++
}
}
if emptyAdjacentCells == len(adjacents) {
return false
}
return true
}
示例8: TileGrowCorporation
// TileGrowCorporation checks if the passed tile grows a corporation.
// Returns true if that's the case, the tiles to append to the corporation and
// the ID of the corporation which grows
func (b *Board) TileGrowCorporation(tl interfaces.Tile) (bool, []interfaces.Tile, interfaces.Corporation) {
tilesToAppend := []interfaces.Tile{tl}
var corporationToGrow, nullCorporation interfaces.Corporation
corporations := b.AdjacentCorporations(tl.Number(), tl.Letter())
if len(corporations) != 1 {
return false, []interfaces.Tile{}, nullCorporation
}
corporationToGrow = corporations[0]
adjacent := b.adjacentTiles(tl.Number(), tl.Letter())
for _, adjacentCell := range adjacent {
if adjacentCell.Type() == interfaces.UnincorporatedOwner {
tilesToAppend = append(tilesToAppend, adjacentCell.(interfaces.Tile))
}
}
return true, tilesToAppend, corporationToGrow
}
示例9: PutTile
// PutTile puts the passed tile on the board
func (b *Board) PutTile(t interfaces.Tile) interfaces.Board {
b.grid[t.Number()][t.Letter()] = t
return b
}