Beispiel #1
0
func (a *SummonAction) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		bx, by := g.GetViewer().WindowToBoard(cursor.Point())
		bx += 0.5
		by += 0.5
		if bx < 0 {
			bx--
		}
		if by < 0 {
			by--
		}
		a.cx = int(bx)
		a.cy = int(by)
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if g.IsCellOccupied(a.cx, a.cy) {
			return true, nil
		}
		if a.Personal_los && !a.ent.HasLos(a.cx, a.cy, 1, 1) {
			return true, nil
		}
		if a.ent.Stats.ApCur() >= a.Ap {
			var exec summonExec
			exec.SetBasicData(a.ent, a)
			exec.Pos = a.ent.Game().ToVertex(a.cx, a.cy)
			return true, &exec
		}
		return true, nil
	}
	return false, nil
}