-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (58 loc) · 2.31 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"encoding/json"
"fmt"
"github.com/K0ntr4/pokemonBattleAdvisor/src"
"time"
)
type currentlyLoadingError struct {
Error string `json:"error"`
EstimatedTime float64 `json:"estimated_time"`
}
func getEnemyPokemon() (enemy pokemonbattleadvisor.Pokemon) {
var err error
var screenshot string
var classifierResult string
screenshot, err = pokemonbattleadvisor.TakeScreenshot(0, 1250, 450, 1600, 800)
if err != nil {
return
}
for i := 0; i < 3; i++ {
classifierResult, err = pokemonbattleadvisor.Classify(screenshot)
if err != nil {
unmarshalErr := currentlyLoadingError{}
_ = json.Unmarshal([]byte(err.Error()), &unmarshalErr)
fmt.Printf("Estimated time: %f\n", unmarshalErr.EstimatedTime)
time.Sleep(3 * time.Second)
}
}
enemy, err = pokemonbattleadvisor.PokemonByName(classifierResult)
if err != nil {
panic(err)
}
pokemonbattleadvisor.PrintHelperStructsPokemon(&enemy)
return enemy
}
func main() {
var enemy = getEnemyPokemon()
var party = []pokemonbattleadvisor.Pokemon{
pokemonbattleadvisor.GetPartyPokemon("weavile", []string{"pressure"}, []string{"poison-jab", "false-swipe", "hail", "blizzard"}),
pokemonbattleadvisor.GetPartyPokemon("clefable", []string{"unaware"}, []string{"moonblast", "flash", "flamethrower", "double-slap"}),
pokemonbattleadvisor.GetPartyPokemon("azumarill", []string{"huge-power"}, []string{"ice-beam", "play-rough", "surf", "hydro-pump"}),
pokemonbattleadvisor.GetPartyPokemon("luxray", []string{"rivalry"}, []string{"thunderbolt", "crunch", "flash", "discharge"}),
pokemonbattleadvisor.GetPartyPokemon("ludicolo", []string{"swift-swim"}, []string{"dive", "surf", "giga-drain", "energy-ball"}),
pokemonbattleadvisor.GetPartyPokemon("sceptile", []string{"overgrow"}, []string{"cut", "dig", "energy-ball", "giga-drain"}),
}
pokemonbattleadvisor.PrintParty(&party)
partyMember, move, shouldSwitch := pokemonbattleadvisor.BestPokemonMoveAndShouldSwitch(&party, &enemy)
if shouldSwitch {
fmt.Println("Should switch")
fmt.Printf("Best party member: %s\n", party[partyMember].Name)
fmt.Println("Best move:")
pokemonbattleadvisor.PrintHelperStructsMove(&party[partyMember].Moves[move])
} else {
fmt.Println("Should not switch")
fmt.Println("Best move:")
pokemonbattleadvisor.PrintHelperStructsMove(&party[partyMember].Moves[move])
}
}