本文整理汇总了Golang中hearts/img/uistate.UIState.CardToPlay方法的典型用法代码示例。如果您正苦于以下问题:Golang UIState.CardToPlay方法的具体用法?Golang UIState.CardToPlay怎么用?Golang UIState.CardToPlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hearts/img/uistate.UIState
的用法示例。
在下文中一共展示了UIState.CardToPlay方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: endClickSplit
func endClickSplit(t touch.Event, u *uistate.UIState) {
if u.CurCard != nil {
if u.CurTable.GetTrick()[u.CurPlayerIndex] == nil {
if dropCardHere(u.CurCard, u.DropTargets[0], t, u) {
if u.CurTable.WhoseTurn() == u.CurPlayerIndex {
ch := make(chan bool)
if err := sync.PlayCard(ch, u.CurPlayerIndex, u); err != "" {
view.ChangePlayMessage(err, u)
if sync.RemoveCardFromTarget(u.CurCard, u) {
u.CardToPlay = nil
u.BackgroundImgs[0].GetNode().Arranger = nil
var emptyTex sprite.SubTex
u.Eng.SetSubTex(u.BackgroundImgs[0].GetNode(), emptyTex)
u.BackgroundImgs[0].SetHidden(true)
}
// add card back to hand
reposition.ResetCardPosition(u.CurCard, u.Eng)
}
} else {
u.CardToPlay = u.CurCard
reposition.AlternateImgs(u.BackgroundImgs[0], u)
}
} else {
// add card back to hand
if sync.RemoveCardFromTarget(u.CurCard, u) {
u.CardToPlay = nil
u.BackgroundImgs[0].GetNode().Arranger = nil
var emptyTex sprite.SubTex
u.Eng.SetSubTex(u.BackgroundImgs[0].GetNode(), emptyTex)
u.BackgroundImgs[0].SetHidden(true)
}
reposition.ResetCardPosition(u.CurCard, u.Eng)
reposition.RealignSuit(u.CurCard.GetSuit(), u.CurCard.GetInitial().Y, u)
}
} else {
// add card back to hand
reposition.ResetCardPosition(u.CurCard, u.Eng)
reposition.RealignSuit(u.CurCard.GetSuit(), u.CurCard.GetInitial().Y, u)
}
}
pressed := getPressed(u)
unpress := true
for _, b := range pressed {
if b == u.Buttons["takeTrick"] {
sync.LogTakeTrick(u)
} else if b == u.Buttons["toggleSplit"] {
unpress = false
}
}
if unpress {
unpressButtons(u)
}
}
示例2: onPlay
func onPlay(value string, u *uistate.UIState) {
// logic
playerInt, curCards := parsePlayerAndCards(value, u)
playedCard := curCards[0]
u.CurTable.GetPlayers()[playerInt].RemoveFromHand(playedCard)
u.CurTable.SetPlayedCard(playedCard, playerInt)
u.CurTable.GetPlayers()[playerInt].SetDonePlaying(true)
trickOver := u.CurTable.TrickOver()
var recipient int
if trickOver {
recipient = u.CurTable.GetTrickRecipient()
}
// UI
if u.CurView == uistate.Table {
sound.PlaySound(0, u)
quit := make(chan bool)
u.AnimChans = append(u.AnimChans, quit)
reposition.AnimateTableCardPlay(playedCard, playerInt, quit, u)
reposition.SetTableDropColors(u)
if trickOver {
// display take trick button
b := u.Buttons["takeTrick"]
u.Eng.SetSubTex(b.GetNode(), b.GetImage())
b.SetHidden(false)
}
} else if u.CurView == uistate.Split {
if playerInt != u.CurPlayerIndex {
quit := make(chan bool)
u.AnimChans = append(u.AnimChans, quit)
reposition.AnimateSplitCardPlay(playedCard, playerInt, quit, u)
}
reposition.SetSplitDropColors(u)
view.LoadSplitView(true, u)
if trickOver {
if recipient == u.CurPlayerIndex {
// display take trick button
b := u.Buttons["takeTrick"]
u.Eng.SetSubTex(b.GetNode(), b.GetImage())
b.SetHidden(false)
}
} else if u.CardToPlay != nil && u.CurTable.WhoseTurn() == u.CurPlayerIndex {
ch := make(chan bool)
if err := PlayCard(ch, u.CurPlayerIndex, u); err != "" {
view.ChangePlayMessage(err, u)
RemoveCardFromTarget(u.CardToPlay, u)
// add card back to hand
reposition.ResetCardPosition(u.CardToPlay, u.Eng)
}
u.CardToPlay = nil
u.BackgroundImgs[0].GetNode().Arranger = nil
var emptyTex sprite.SubTex
u.Eng.SetSubTex(u.BackgroundImgs[0].GetNode(), emptyTex)
u.BackgroundImgs[0].SetHidden(true)
}
} else if u.CurView == uistate.Play && u.CurPlayerIndex != playerInt {
view.LoadPlayView(true, u)
if u.CardToPlay != nil && u.CurTable.WhoseTurn() == u.CurPlayerIndex {
ch := make(chan bool)
if err := PlayCard(ch, u.CurPlayerIndex, u); err != "" {
view.ChangePlayMessage(err, u)
RemoveCardFromTarget(u.CardToPlay, u)
// add card back to hand
reposition.ResetCardPosition(u.CardToPlay, u.Eng)
reposition.RealignSuit(u.CardToPlay.GetSuit(), u.CardToPlay.GetInitial().Y, u)
}
u.CardToPlay = nil
quit := make(chan bool)
u.AnimChans = append(u.AnimChans, quit)
go func() {
onDone := func() {
if u.CurView == uistate.Play {
view.LoadPlayView(true, u)
}
}
reposition.SwitchOnChan(ch, quit, onDone, u)
}()
}
}
}
示例3: endClickPlay
func endClickPlay(t touch.Event, u *uistate.UIState) {
if u.CurCard != nil {
if u.CurTable.GetTrick()[u.CurPlayerIndex] == nil {
if dropCardOnTarget(u.CurCard, t, u) {
if u.CurTable.WhoseTurn() == u.CurPlayerIndex {
ch := make(chan bool)
if err := sync.PlayCard(ch, u.CurPlayerIndex, u); err != "" {
view.ChangePlayMessage(err, u)
sync.RemoveCardFromTarget(u.CurCard, u)
u.CardToPlay = nil
// add card back to hand
reposition.ResetCardPosition(u.CurCard, u.Eng)
reposition.RealignSuit(u.CurCard.GetSuit(), u.CurCard.GetInitial().Y, u)
}
quit := make(chan bool)
u.AnimChans = append(u.AnimChans, quit)
go func() {
onDone := func() {
if u.CurView == uistate.Play {
view.LoadPlayView(true, u)
}
}
reposition.SwitchOnChan(ch, quit, onDone, u)
}()
} else {
u.CardToPlay = u.CurCard
}
} else {
// add card back to hand
if sync.RemoveCardFromTarget(u.CurCard, u) {
u.CardToPlay = nil
}
reposition.ResetCardPosition(u.CurCard, u.Eng)
reposition.RealignSuit(u.CurCard.GetSuit(), u.CurCard.GetInitial().Y, u)
}
} else {
// add card back to hand
reposition.ResetCardPosition(u.CurCard, u.Eng)
reposition.RealignSuit(u.CurCard.GetSuit(), u.CurCard.GetInitial().Y, u)
}
}
pressed := unpressButtons(u)
for _, b := range pressed {
if b == u.Buttons["takeTrick"] {
var emptyTex sprite.SubTex
u.Eng.SetSubTex(b.GetNode(), emptyTex)
b.SetHidden(true)
u.Buttons["takeTrick"] = nil
for _, takenCard := range u.TableCards {
sync.RemoveCardFromTarget(takenCard, u)
reposition.BringNodeToFront(takenCard.GetNode(), u)
}
ch := make(chan bool)
reposition.AnimateHandCardTakeTrick(ch, u.TableCards, u)
quit := make(chan bool)
u.AnimChans = append(u.AnimChans, quit)
go func() {
onDone := func() {
sync.LogTakeTrick(u)
}
reposition.SwitchOnChan(ch, quit, onDone, u)
}()
}
}
}