コード例 #1
0
func scan(ship *dtl.Ship) ([]*dtl.Ship, []*dtl.Sector, error) {
	for {
		if ship.CanScan() {
			return ship.ScanSector()
		}
		time.Sleep(1 * time.Second)
	}
}
コード例 #2
0
func evac(ship *dtl.Ship, escapeSector *dtl.Sector) error {
	for {
		if ship.CanTravel() {
			fmt.Printf("Evaccing to %s\n", escapeSector.Name)
			return ship.Travel(escapeSector)
		}
		time.Sleep(1 * time.Second)
	}
}
コード例 #3
0
func travel(ship *dtl.Ship, sector *dtl.Sector) error {
	for {
		if ship.CanTravel() {
			fmt.Printf("Travelling to %s\n", sector.Name)
			return ship.Travel(sector)
		}
		time.Sleep(1 * time.Second)
	}
}
コード例 #4
0
func fireLoop(ship, target *dtl.Ship) error {
	for {
		if ship.CanFire() {
			fmt.Printf("Fixing on %s\n", target.Name)
			if err := ship.Fire(target.Name); err != nil {
				fmt.Println("Fail!")
				return err
			} else {
				fmt.Println("HIT!")
			}
		}
		time.Sleep(1 * time.Second)
	}
}