// check coordinates and start event func (this *WorldMap) StartEvent(w, x, y, z int) { tile := this.getTile(w, x, y, z) r := rand.New(rand.NewSource(time.Now().UnixNano())) switch tile { case VOID: fmt.Println("Where are you? There's nothing here!") case FIELD: // 50% chance of spawning monster fmt.Println("You are in a field.") if r.Intn(10) < 5 { startBattle(w, x, y, z) } case FORREST: // 70% chance of spawning monster fmt.Println("You are in a forrest.") if r.Intn(10) < 7 { startBattle(w, x, y, z) } case RIVER: // 30% chance of spawning monster fmt.Println("You are in a river.") if r.Intn(10) < 3 { startBattle(w, x, y, z) } case OCEAN: // 50% chance of spawning monster fmt.Println("You are in the ocean.") if r.Intn(10) < 5 { startBattle(w, x, y, z) } default: // print error message tool.DPrintlnErr() } }
// start a new player by assigning the input character as the player func initPlayer() { var newChar string tool.DPrint("Choose your character: ") fmt.Scan(&newChar) upperNewChar := strings.ToUpper(newChar) switch upperNewChar { case "ALPHA": player = entity.Alpha case "ELIZE": player = entity.Elize case "DIVYA": player = entity.Divya default: tool.DPrintlnErr() // print error initPlayer() // recursive repeat } }