示例#1
0
func (b *Board) addCollisions(c collisionMap, ts botapi.Turn_List) {
	for i := 0; i < ts.Len(); i++ {
		t := ts.At(i)
		id := RobotID(t.Id())
		nextLoc := b.nextLoc(id, t)
		// Add where they want to move
		c[nextLoc] = append(c[nextLoc], id)
	}
}
示例#2
0
func (b *Board) issueSelfDestructs(ts botapi.Turn_List) {
	for i := 0; i < ts.Len(); i++ {
		t := ts.At(i)
		if t.Which() != botapi.Turn_Which_selfDestruct {
			continue
		}

		// They're Metro-booming on production:
		// (https://www.youtube.com/watch?v=NiM5ARaexPE)
		loc := b.robotLoc(RobotID(t.Id()))
		for _, boomLoc := range b.surrounding(loc) {
			// If there's a bot in the blast radius
			victim := b.At(boomLoc)
			if victim != nil {
				b.hurtBot(victim, DestructDamage)
			}
		}

		bomber := b.At(loc)
		// Kill 'em
		b.hurtBot(bomber, SelfDamage)
	}
}
示例#3
0
func (b *Board) issueAttacks(ts botapi.Turn_List) {
	for i := 0; i < ts.Len(); i++ {
		t := ts.At(i)
		if t.Which() != botapi.Turn_Which_attack {
			continue
		}

		// They're attacking
		loc := b.robotLoc(RobotID(t.Id()))
		xOff, yOff := directionOffsets(t.Attack())
		attackLoc := Loc{
			X: loc.X + xOff,
			Y: loc.Y + yOff,
		}

		// If there's a bot at the attack location, make them sad
		// NOTE: You *can* hurt attack your own robots
		victim := b.At(attackLoc)
		if victim != nil {
			b.hurtBot(victim, AttackDamage)
		}
	}
}