Пример #1
0
func beginClickSplit(t touch.Event, u *uistate.UIState) {
	u.CurCard = findClickedCard(t, u)
	if u.CurCard != nil {
		reposition.BringNodeToFront(u.CurCard.GetNode(), u)
	}
	buttonList := findClickedButton(t, u)
	for _, b := range buttonList {
		if b == u.Buttons["toggleSplit"] && !u.SwitchingViews {
			ch := make(chan bool)
			u.SwitchingViews = true
			reposition.AnimateOutSplit(ch, u)
			quit := make(chan bool)
			u.AnimChans = append(u.AnimChans, quit)
			go func() {
				onDone := func() {
					u.SwitchingViews = false
					if u.CurView == uistate.Split {
						view.LoadPlayView(false, u)
					}
				}
				reposition.SwitchOnChan(ch, quit, onDone, u)
			}()
		} else if b == u.Buttons["takeTrick"] {
			pressButton(b, u)
		} else {
			handleDebugButtonClick(b, u)
		}
	}
}
Пример #2
0
func beginClickPass(t touch.Event, u *uistate.UIState) {
	u.CurCard = findClickedCard(t, u)
	if u.CurCard != nil {
		reposition.BringNodeToFront(u.CurCard.GetNode(), u)
	}
	buttonList := findClickedButton(t, u)
	for _, b := range buttonList {
		if b == u.Buttons["pass"] {
			pressButton(b, u)
		} else {
			handleDebugButtonClick(b, u)
		}
	}
}
Пример #3
0
func beginClickPlay(t touch.Event, u *uistate.UIState) {
	u.CurCard = findClickedCard(t, u)
	if u.CurCard != nil {
		reposition.BringNodeToFront(u.CurCard.GetNode(), u)
	}
	buttonList := findClickedButton(t, u)
	for _, b := range buttonList {
		if b == u.Buttons["toggleSplit"] && !u.SwitchingViews {
			view.LoadSplitView(false, u)
		} else if b == u.Buttons["takeTrick"] {
			pressButton(b, u)
		} else {
			handleDebugButtonClick(b, u)
		}
	}
}
Пример #4
0
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)
			}()
		}
	}
}