Esempio n. 1
0
func NewShielder(g interfaces.Game) interfaces.Entity {
	me := newBasicMonster(g)
	me.SetSubtype(interfaces.ENTITY_MONSTER_SUBTYPE_SHIELDER)
	me.SetName("Shielder " + strconv.Itoa(me.GetEntityId()))
	me.SetMaxArdour(50)
	me.SetArdour(50)

	push := make(map[string]interfaces.Action)
	push["left"] = order.NewAction("pl")
	push["right"] = order.NewAction("pr")
	push["up"] = order.NewAction("pu")
	push["down"] = order.NewAction("pd")

	me.TurnFunction = func(tick int) bool {
		foundAny := false

		for _, action := range push {
			if err := action.Act(me, me.Game); err == nil {
				foundAny = true
			}
		}

		return foundAny
	}

	return me
}
Esempio n. 2
0
func New(g interfaces.Game) *Player {
	p := &Player{}

	/* Spectator stuff */
	p.Spectator = spectator.New()

	/* Player stuff */
	p.SetPlayerId(uidg.NextUid())
	p.SetLastTickTime(time.Now())
	p.AvailableActions = append(p.AvailableActions, order.NewAction("."))
	p.AvailableActions = append(p.AvailableActions, order.NewAction("mu"))
	p.AvailableActions = append(p.AvailableActions, order.NewAction("*u"))
	p.AvailableActions = append(p.AvailableActions, order.NewAction("lu"))

	/* Entity stuff */
	p.Entity = entity.New(entity.UIDG.NextUid(), g)
	p.SetType(interfaces.ENTITY_TYPE_PLAYER)
	p.SetName("Player " + strconv.Itoa(p.GetPlayerId()))
	p.SetMaxArdour(100)
	p.SetArdour(100)

	return p
}