本文整理汇总了Golang中github.com/twoodhouse/coup-sim/model/log.Entity类的典型用法代码示例。如果您正苦于以下问题:Golang Entity类的具体用法?Golang Entity怎么用?Golang Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetStealBlockCardChoice
func (entity *Entity) GetStealBlockCardChoice(log *log.Entity, playerNames []string, coinInfo map[string]int, faceupInfo map[string][]int, deck *deck.Entity) int {
fmt.Println(log.PrettyJsonStr())
printPersonalTable(entity.playerName, playerNames, coinInfo, faceupInfo, deck)
var choice int
fmt.Printf("GetStealBlockCardChoice:\n> ")
fmt.Scanf("%d\n", &choice)
return choice
}
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:8,代码来源:consoleStrategy.go
示例2: GetBlock
func (entity *Entity) GetBlock(log *log.Entity, playerNames []string, coinInfo map[string]int, faceupInfo map[string][]int, deck *deck.Entity) bool {
fmt.Println(log.PrettyJsonStr())
printPersonalTable(entity.playerName, playerNames, coinInfo, faceupInfo, deck)
var block bool
fmt.Printf("GetBlock:\n> ")
fmt.Scanf("%t\n", &block)
return block
}
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:8,代码来源:consoleStrategy.go
示例3: GetChallenge
func (entity *Entity) GetChallenge(log *log.Entity, playerNames []string, coinInfo map[string]int, faceupInfo map[string][]int, deck *deck.Entity) bool {
fmt.Println(log.PrettyJsonStr())
printPersonalTable(entity.playerName, playerNames, coinInfo, faceupInfo, deck)
var challenge bool
fmt.Printf("GetChallenge:\n> ")
fmt.Scanf("%t\n", &challenge)
return challenge
}
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:8,代码来源:consoleStrategy.go
示例4: GetTarget
func (entity *Entity) GetTarget(log *log.Entity, playerNames []string, coinInfo map[string]int, faceupInfo map[string][]int, deck *deck.Entity) string {
fmt.Println(log.PrettyJsonStr())
printPersonalTable(entity.playerName, playerNames, coinInfo, faceupInfo, deck)
var target string
fmt.Printf("GetTarget:\n> ")
fmt.Scanf("%s\n", &target)
return target
}
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:8,代码来源:consoleStrategy.go
示例5: GetExchangeReturnChoices
func (entity *Entity) GetExchangeReturnChoices(log *log.Entity, playerNames []string, coinInfo map[string]int, faceupInfo map[string][]int, deck *deck.Entity) (int, int) {
fmt.Println(log.PrettyJsonStr())
// fmt.Printf("Cards gained by using exchange: %d%d\n", c1, c2)
printPersonalTable(entity.playerName, playerNames, coinInfo, faceupInfo, deck)
var r1 int
fmt.Printf("GetExchangeReturnChoices(1):\n> ")
fmt.Scanf("%d\n", &r1)
var r2 int
fmt.Printf("GetExchangeReturnChoices(2):\n> ")
fmt.Scanf("%d\n", &r2)
return r1, r2
}
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:12,代码来源:consoleStrategy.go
示例6: disqualifyPlayer
func disqualifyPlayer(player *player.Entity, table *table.Entity, log *log.Entity, reason string) {
player.Kill()
disqualifiedPlayerFaceupDeck := table.FaceupDecks()[player.Name()]
if disqualifiedPlayerFaceupDeck[0] != 0 {
disqualifiedPlayerFaceupDeck[1] = disqualifiedPlayerFaceupDeck[0]
}
disqualifiedPlayerFaceupDeck[0] = player.Deck().TakeTopCard()
if player.Deck().Size() > 0 {
disqualifiedPlayerFaceupDeck := table.FaceupDecks()[player.Name()]
if disqualifiedPlayerFaceupDeck[0] != 0 {
disqualifiedPlayerFaceupDeck[1] = disqualifiedPlayerFaceupDeck[0]
}
disqualifiedPlayerFaceupDeck[0] = player.Deck().TakeTopCard()
}
log.CreateDisqualify(reason)
}
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:16,代码来源:controller.go
示例7: DoTurn
//order of turn operation:
//1. Assign action and target
//2. Check general challenge concerning action
//3. Check block from targeted player
//4. Check challenge concerning block from source player
//5. Set action results given challenge/block success
func DoTurn(player *player.Entity, otherPlayers []*player.Entity, log *log.Entity, table *table.Entity, turnCounter int) (*log.Entity, *table.Entity) {
log.SetPlayerName(player.Name())
action := player.Strategy().GetAction(log, table.PlayerNames(), table.PlayerCoins(), table.FaceupDecks(), player.Deck())
targetedPlayer := player //set default - not used unless assassinate or steal happens
log.SetActionName(action)
challengeLoss := false
var target string
//mid-game coin outputs
// fmt.Print(player.Name() + ": ")
// fmt.Print(player.Coins())
// fmt.Println()
if !player.Dead() && action != "tax" && action != "income" && action != "foreign_aid" && action != "coup" && action != "steal" && action != "assassinate" && action != "exchange" && action != "coup" {
disqualifyPlayer(player, table, log, "Player attempted invalid action "+action)
}
if action != "coup" && player.Coins() >= 10 && !player.Dead() {
disqualifyPlayer(player, table, log, "Player had 10+ coins and did not coup")
}
if action == "coup" && player.Coins() < 7 && !player.Dead() {
disqualifyPlayer(player, table, log, "Player had "+strconv.Itoa(player.Coins())+" coins and needed 7 to Coup")
}
if action == "assassinate" && !player.Dead() {
if player.Coins() < 3 {
disqualifyPlayer(player, table, log, "Player had "+strconv.Itoa(player.Coins())+" coins and needed 3 to Assassinate")
} else {
player.AddCoins(-3)
}
}
//get target for certain actions
if action == "steal" || action == "assassinate" || action == "coup" && !player.Dead() {
target = player.Strategy().GetTarget(log, table.PlayerNames(), table.PlayerCoins(), table.FaceupDecks(), player.Deck())
if validLiveOtherPlayerName(otherPlayers, target) {
targetedPlayer = playerByName(otherPlayers, target)
log.CreateTarget(target)
} else {
disqualifyPlayer(player, table, log, "Target '"+target+"' is not a valid opposing-player name")
}
}
//top-level challenge logic - it can only happen with these actions
if (action == "tax" || action == "steal" || action == "assassinate" || action == "exchange") && !player.Dead() {
for i := 0; i < len(otherPlayers); i++ {
if !otherPlayers[i].Dead() && otherPlayers[i].Strategy().GetChallenge(log, table.PlayerNames(), table.PlayerCoins(), table.FaceupDecks(), otherPlayers[i].Deck()) {
challengeSuccess := !player.Deck().HasCardForAction(action)
losingPlayer := player
if challengeSuccess {
challengeLoss = true
losingPlayer = player
} else {
losingPlayer = otherPlayers[i]
var cardValue int
switch action {
case "tax":
cardValue = 1
case "steal":
cardValue = 2
case "assassinate":
cardValue = 3
case "block":
cardValue = 4
case "exchange":
cardValue = 5
}
swapChallengedCard(player, table, log, cardValue)
}
log.CreateChallenge(otherPlayers[i].Name(), challengeSuccess)
cardLoss := revealCard(losingPlayer, table, log)
log.CreateChallengeCardLoss(cardLoss)
break
}
}
}
if (action == "steal" || action == "assassinate") && !player.Dead() && !challengeLoss && !targetedPlayer.Dead() {
if targetedPlayer.Strategy().GetBlock(log, table.PlayerNames(), table.PlayerCoins(), table.FaceupDecks(), targetedPlayer.Deck()) {
log.CreateBlock()
var blockCardClaim int
if action == "steal" {
blockCardClaim = targetedPlayer.Strategy().GetStealBlockCardChoice(log, table.PlayerNames(), table.PlayerCoins(), table.FaceupDecks(), targetedPlayer.Deck())
log.CreateBlockCardClaim(blockCardClaim)
if blockCardClaim != 2 && blockCardClaim != 5 {
disqualifyPlayer(targetedPlayer, table, log, "Block card '"+strconv.Itoa(blockCardClaim)+"' is not valid for blocking steal'")
}
}
if player.Strategy().GetChallenge(log, table.PlayerNames(), table.PlayerCoins(), table.FaceupDecks(), player.Deck()) {
var neededCardAction string
if action == "steal" {
if blockCardClaim == 2 {
neededCardAction = "steal"
//.........这里部分代码省略.........
开发者ID:twoodhouse,项目名称:coup-sim,代码行数:101,代码来源:controller.go
注:本文中的github.com/twoodhouse/coup-sim/model/log.Entity类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论