pokemonbattlelib

package module
v0.0.0-...-e52df5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

README

Pokemon Battle Library

A portable library for accurately simulating pokemon battles.

CI Test codecov

Usage

Documentation

Basic Example Battle
p1 := GeneratePokemon(PkmnPikachu,
	WithLevel(20),
	WithMoves(MoveThunderShock))
p2 := GeneratePokemon(PkmnBulbasaur,
	WithLevel(20),
	WithMoves(MoveTackle))
a1 := Agent(new(dumbAgent))
b := New1v1Battle(p1, &a1, p2, &a1)
b.Start()
transactions, _ := b.SimulateRound()
for _, t := range transactions {
	switch tt := t.(type) {
	case UseMoveTransaction:
		fmt.Printf("%s used %s on %s\n", b.GetPokemon(tt.User), tt.Move, b.GetPokemon(tt.Target))
	case DamageTransaction:
		fmt.Printf("%s took %d damage\n", b.GetPokemon(tt.Target), tt.Damage)
	case HealTransaction:
		fmt.Printf("%s healed for %d HP\n", b.GetPokemon(tt.Target), tt.Amount)
	case FaintTransaction:
		fmt.Printf("%s fainted\n", b.GetPokemon(tt.Target))
	case PPTransaction:
		continue
	default:
		fmt.Printf("Transaction: %T - %v\n", t, t)
	}
}

Contributing

  1. Make sure that you at least have Go 1.15
  2. Clone this repo
git clone git@github.com:StevensSEC/pokemonbattlelib.git
  1. Make and commit your changes.
  2. Create a Pull Request with your changes.

Using the github cli:

gh pr create

Documentation

Overview

pokemonbattlelib is a library for simulating pokemon battles using rules up to generation 4 (currently).

Battles are represented as the result of a sequence of Transactions. Transactions define what state needs to change, and can queue up subsequent transactions via Mutate. Agents control Parties. Each round, each active (on the battlefield) Pokemon gets one Turn. The Agent that controls the Party of the Pokemon dictates what Turn the Pokemon will make. Then, the Turns queue up Transactions accordingly.

Index

Examples

Constants

View Source
const (
	ItemCategoryStatBoost ItemCategory = iota + 1
	ItemCategoryEffortDrop
	ItemCategoryMedicine
	ItemCategoryOther
	ItemCategoryInAPinch
	ItemCategoryPickyHealing
	ItemCategoryTypeProtection
	ItemCategoryBakingOnly
	ItemCategoryCollectibles
	ItemCategoryEvolution
	ItemCategorySpelunking
	ItemCategoryHeldItems
	ItemCategoryChoice
	ItemCategoryEffortTraining
	ItemCategoryBadHeldItems
	ItemCategoryTraining
	ItemCategoryPlates
	ItemCategorySpeciesSpecific
	ItemCategoryTypeEnhancement
	ItemCategoryEventItems
	ItemCategoryGameplay
	ItemCategoryPlotAdvancement
	ItemCategoryUnused
	ItemCategoryLoot
	ItemCategoryAllMail
	// Medicine
	ItemCategoryVitamins
	ItemCategoryHealing
	ItemCategoryPPRecovery
	ItemCategoryRevival
	ItemCategoryStatusCures
	// Category 31 does not exist
	ItemCategoryMulch = iota + 2
	ItemCategorySpecialBalls
	ItemCategoryStandardBalls
	ItemCategoryDexCompletion
	ItemCategoryScarves
	ItemCategoryAllMachines
	ItemCategoryFlutes
	ItemCategoryApricornBalls
	ItemCategoryApricornBox
	ItemCategoryDataCards
	ItemCategoryJewels
	ItemCategoryMiracleShooter
	ItemCategoryMegaStones
	ItemCategoryMemories
	ItemCategoryZCrystals
)

Fix: remove unnecessary items

View Source
const (
	MovePriorityMin = 5
	MovePriorityMax = -7
)

Sets the bounds on move priority to [-7, 5]

View Source
const (
	PkmnBulbasaur  = 1
	PkmnIvysaur    = 2
	PkmnVenusaur   = 3
	PkmnCharmander = 4
	PkmnCharmeleon = 5
	PkmnCharizard  = 6
	PkmnSquirtle   = 7
	PkmnWartortle  = 8
	PkmnBlastoise  = 9
	PkmnCaterpie   = 10
	PkmnMetapod    = 11
	PkmnButterfree = 12
	PkmnWeedle     = 13
	PkmnKakuna     = 14
	PkmnBeedrill   = 15
	PkmnPidgey     = 16
	PkmnPidgeotto  = 17
	PkmnPidgeot    = 18
	PkmnRattata    = 19
	PkmnRaticate   = 20
	PkmnSpearow    = 21
	PkmnFearow     = 22
	PkmnEkans      = 23
	PkmnArbok      = 24
	PkmnPikachu    = 25
	PkmnRaichu     = 26
	PkmnSandshrew  = 27
	PkmnSandslash  = 28
	PkmnNidoranF   = 29
	PkmnNidorina   = 30
	PkmnNidoqueen  = 31
	PkmnNidoranM   = 32
	PkmnNidorino   = 33
	PkmnNidoking   = 34
	PkmnClefairy   = 35
	PkmnClefable   = 36
	PkmnVulpix     = 37
	PkmnNinetales  = 38
	PkmnJigglypuff = 39
	PkmnWigglytuff = 40
	PkmnZubat      = 41
	PkmnGolbat     = 42
	PkmnOddish     = 43
	PkmnGloom      = 44
	PkmnVileplume  = 45
	PkmnParas      = 46
	PkmnParasect   = 47
	PkmnVenonat    = 48
	PkmnVenomoth   = 49
	PkmnDiglett    = 50
	PkmnDugtrio    = 51
	PkmnMeowth     = 52
	PkmnPersian    = 53
	PkmnPsyduck    = 54
	PkmnGolduck    = 55
	PkmnMankey     = 56
	PkmnPrimeape   = 57
	PkmnGrowlithe  = 58
	PkmnArcanine   = 59
	PkmnPoliwag    = 60
	PkmnPoliwhirl  = 61
	PkmnPoliwrath  = 62
	PkmnAbra       = 63
	PkmnKadabra    = 64
	PkmnAlakazam   = 65
	PkmnMachop     = 66
	PkmnMachoke    = 67
	PkmnMachamp    = 68
	PkmnBellsprout = 69
	PkmnWeepinbell = 70
	PkmnVictreebel = 71
	PkmnTentacool  = 72
	PkmnTentacruel = 73
	PkmnGeodude    = 74
	PkmnGraveler   = 75
	PkmnGolem      = 76
	PkmnPonyta     = 77
	PkmnRapidash   = 78
	PkmnSlowpoke   = 79
	PkmnSlowbro    = 80
	PkmnMagnemite  = 81
	PkmnMagneton   = 82
	PkmnFarfetchd  = 83
	PkmnDoduo      = 84
	PkmnDodrio     = 85
	PkmnSeel       = 86
	PkmnDewgong    = 87
	PkmnGrimer     = 88
	PkmnMuk        = 89
	PkmnShellder   = 90
	PkmnCloyster   = 91
	PkmnGastly     = 92
	PkmnHaunter    = 93
	PkmnGengar     = 94
	PkmnOnix       = 95
	PkmnDrowzee    = 96
	PkmnHypno      = 97
	PkmnKrabby     = 98
	PkmnKingler    = 99
	PkmnVoltorb    = 100
	PkmnElectrode  = 101
	PkmnExeggcute  = 102
	PkmnExeggutor  = 103
	PkmnCubone     = 104
	PkmnMarowak    = 105
	PkmnHitmonlee  = 106
	PkmnHitmonchan = 107
	PkmnLickitung  = 108
	PkmnKoffing    = 109
	PkmnWeezing    = 110
	PkmnRhyhorn    = 111
	PkmnRhydon     = 112
	PkmnChansey    = 113
	PkmnTangela    = 114
	PkmnKangaskhan = 115
	PkmnHorsea     = 116
	PkmnSeadra     = 117
	PkmnGoldeen    = 118
	PkmnSeaking    = 119
	PkmnStaryu     = 120
	PkmnStarmie    = 121
	PkmnMrMime     = 122
	PkmnScyther    = 123
	PkmnJynx       = 124
	PkmnElectabuzz = 125
	PkmnMagmar     = 126
	PkmnPinsir     = 127
	PkmnTauros     = 128
	PkmnMagikarp   = 129
	PkmnGyarados   = 130
	PkmnLapras     = 131
	PkmnDitto      = 132
	PkmnEevee      = 133
	PkmnVaporeon   = 134
	PkmnJolteon    = 135
	PkmnFlareon    = 136
	PkmnPorygon    = 137
	PkmnOmanyte    = 138
	PkmnOmastar    = 139
	PkmnKabuto     = 140
	PkmnKabutops   = 141
	PkmnAerodactyl = 142
	PkmnSnorlax    = 143
	PkmnArticuno   = 144
	PkmnZapdos     = 145
	PkmnMoltres    = 146
	PkmnDratini    = 147
	PkmnDragonair  = 148
	PkmnDragonite  = 149
	PkmnMewtwo     = 150
	PkmnMew        = 151
	PkmnChikorita  = 152
	PkmnBayleef    = 153
	PkmnMeganium   = 154
	PkmnCyndaquil  = 155
	PkmnQuilava    = 156
	PkmnTyphlosion = 157
	PkmnTotodile   = 158
	PkmnCroconaw   = 159
	PkmnFeraligatr = 160
	PkmnSentret    = 161
	PkmnFurret     = 162
	PkmnHoothoot   = 163
	PkmnNoctowl    = 164
	PkmnLedyba     = 165
	PkmnLedian     = 166
	PkmnSpinarak   = 167
	PkmnAriados    = 168
	PkmnCrobat     = 169
	PkmnChinchou   = 170
	PkmnLanturn    = 171
	PkmnPichu      = 172
	PkmnCleffa     = 173
	PkmnIgglybuff  = 174
	PkmnTogepi     = 175
	PkmnTogetic    = 176
	PkmnNatu       = 177
	PkmnXatu       = 178
	PkmnMareep     = 179
	PkmnFlaaffy    = 180
	PkmnAmpharos   = 181
	PkmnBellossom  = 182
	PkmnMarill     = 183
	PkmnAzumarill  = 184
	PkmnSudowoodo  = 185
	PkmnPolitoed   = 186
	PkmnHoppip     = 187
	PkmnSkiploom   = 188
	PkmnJumpluff   = 189
	PkmnAipom      = 190
	PkmnSunkern    = 191
	PkmnSunflora   = 192
	PkmnYanma      = 193
	PkmnWooper     = 194
	PkmnQuagsire   = 195
	PkmnEspeon     = 196
	PkmnUmbreon    = 197
	PkmnMurkrow    = 198
	PkmnSlowking   = 199
	PkmnMisdreavus = 200
	PkmnUnown      = 201
	PkmnWobbuffet  = 202
	PkmnGirafarig  = 203
	PkmnPineco     = 204
	PkmnForretress = 205
	PkmnDunsparce  = 206
	PkmnGligar     = 207
	PkmnSteelix    = 208
	PkmnSnubbull   = 209
	PkmnGranbull   = 210
	PkmnQwilfish   = 211
	PkmnScizor     = 212
	PkmnShuckle    = 213
	PkmnHeracross  = 214
	PkmnSneasel    = 215
	PkmnTeddiursa  = 216
	PkmnUrsaring   = 217
	PkmnSlugma     = 218
	PkmnMagcargo   = 219
	PkmnSwinub     = 220
	PkmnPiloswine  = 221
	PkmnCorsola    = 222
	PkmnRemoraid   = 223
	PkmnOctillery  = 224
	PkmnDelibird   = 225
	PkmnMantine    = 226
	PkmnSkarmory   = 227
	PkmnHoundour   = 228
	PkmnHoundoom   = 229
	PkmnKingdra    = 230
	PkmnPhanpy     = 231
	PkmnDonphan    = 232
	PkmnPorygon2   = 233
	PkmnStantler   = 234
	PkmnSmeargle   = 235
	PkmnTyrogue    = 236
	PkmnHitmontop  = 237
	PkmnSmoochum   = 238
	PkmnElekid     = 239
	PkmnMagby      = 240
	PkmnMiltank    = 241
	PkmnBlissey    = 242
	PkmnRaikou     = 243
	PkmnEntei      = 244
	PkmnSuicune    = 245
	PkmnLarvitar   = 246
	PkmnPupitar    = 247
	PkmnTyranitar  = 248
	PkmnLugia      = 249
	PkmnHoOh       = 250
	PkmnCelebi     = 251
	PkmnTreecko    = 252
	PkmnGrovyle    = 253
	PkmnSceptile   = 254
	PkmnTorchic    = 255
	PkmnCombusken  = 256
	PkmnBlaziken   = 257
	PkmnMudkip     = 258
	PkmnMarshtomp  = 259
	PkmnSwampert   = 260
	PkmnPoochyena  = 261
	PkmnMightyena  = 262
	PkmnZigzagoon  = 263
	PkmnLinoone    = 264
	PkmnWurmple    = 265
	PkmnSilcoon    = 266
	PkmnBeautifly  = 267
	PkmnCascoon    = 268
	PkmnDustox     = 269
	PkmnLotad      = 270
	PkmnLombre     = 271
	PkmnLudicolo   = 272
	PkmnSeedot     = 273
	PkmnNuzleaf    = 274
	PkmnShiftry    = 275
	PkmnTaillow    = 276
	PkmnSwellow    = 277
	PkmnWingull    = 278
	PkmnPelipper   = 279
	PkmnRalts      = 280
	PkmnKirlia     = 281
	PkmnGardevoir  = 282
	PkmnSurskit    = 283
	PkmnMasquerain = 284
	PkmnShroomish  = 285
	PkmnBreloom    = 286
	PkmnSlakoth    = 287
	PkmnVigoroth   = 288
	PkmnSlaking    = 289
	PkmnNincada    = 290
	PkmnNinjask    = 291
	PkmnShedinja   = 292
	PkmnWhismur    = 293
	PkmnLoudred    = 294
	PkmnExploud    = 295
	PkmnMakuhita   = 296
	PkmnHariyama   = 297
	PkmnAzurill    = 298
	PkmnNosepass   = 299
	PkmnSkitty     = 300
	PkmnDelcatty   = 301
	PkmnSableye    = 302
	PkmnMawile     = 303
	PkmnAron       = 304
	PkmnLairon     = 305
	PkmnAggron     = 306
	PkmnMeditite   = 307
	PkmnMedicham   = 308
	PkmnElectrike  = 309
	PkmnManectric  = 310
	PkmnPlusle     = 311
	PkmnMinun      = 312
	PkmnVolbeat    = 313
	PkmnIllumise   = 314
	PkmnRoselia    = 315
	PkmnGulpin     = 316
	PkmnSwalot     = 317
	PkmnCarvanha   = 318
	PkmnSharpedo   = 319
	PkmnWailmer    = 320
	PkmnWailord    = 321
	PkmnNumel      = 322
	PkmnCamerupt   = 323
	PkmnTorkoal    = 324
	PkmnSpoink     = 325
	PkmnGrumpig    = 326
	PkmnSpinda     = 327
	PkmnTrapinch   = 328
	PkmnVibrava    = 329
	PkmnFlygon     = 330
	PkmnCacnea     = 331
	PkmnCacturne   = 332
	PkmnSwablu     = 333
	PkmnAltaria    = 334
	PkmnZangoose   = 335
	PkmnSeviper    = 336
	PkmnLunatone   = 337
	PkmnSolrock    = 338
	PkmnBarboach   = 339
	PkmnWhiscash   = 340
	PkmnCorphish   = 341
	PkmnCrawdaunt  = 342
	PkmnBaltoy     = 343
	PkmnClaydol    = 344
	PkmnLileep     = 345
	PkmnCradily    = 346
	PkmnAnorith    = 347
	PkmnArmaldo    = 348
	PkmnFeebas     = 349
	PkmnMilotic    = 350
	PkmnCastform   = 351
	PkmnKecleon    = 352
	PkmnShuppet    = 353
	PkmnBanette    = 354
	PkmnDuskull    = 355
	PkmnDusclops   = 356
	PkmnTropius    = 357
	PkmnChimecho   = 358
	PkmnAbsol      = 359
	PkmnWynaut     = 360
	PkmnSnorunt    = 361
	PkmnGlalie     = 362
	PkmnSpheal     = 363
	PkmnSealeo     = 364
	PkmnWalrein    = 365
	PkmnClamperl   = 366
	PkmnHuntail    = 367
	PkmnGorebyss   = 368
	PkmnRelicanth  = 369
	PkmnLuvdisc    = 370
	PkmnBagon      = 371
	PkmnShelgon    = 372
	PkmnSalamence  = 373
	PkmnBeldum     = 374
	PkmnMetang     = 375
	PkmnMetagross  = 376
	PkmnRegirock   = 377
	PkmnRegice     = 378
	PkmnRegisteel  = 379
	PkmnLatias     = 380
	PkmnLatios     = 381
	PkmnKyogre     = 382
	PkmnGroudon    = 383
	PkmnRayquaza   = 384
	PkmnJirachi    = 385
	PkmnDeoxys     = 386
	PkmnTurtwig    = 387
	PkmnGrotle     = 388
	PkmnTorterra   = 389
	PkmnChimchar   = 390
	PkmnMonferno   = 391
	PkmnInfernape  = 392
	PkmnPiplup     = 393
	PkmnPrinplup   = 394
	PkmnEmpoleon   = 395
	PkmnStarly     = 396
	PkmnStaravia   = 397
	PkmnStaraptor  = 398
	PkmnBidoof     = 399
	PkmnBibarel    = 400
	PkmnKricketot  = 401
	PkmnKricketune = 402
	PkmnShinx      = 403
	PkmnLuxio      = 404
	PkmnLuxray     = 405
	PkmnBudew      = 406
	PkmnRoserade   = 407
	PkmnCranidos   = 408
	PkmnRampardos  = 409
	PkmnShieldon   = 410
	PkmnBastiodon  = 411
	PkmnBurmy      = 412
	PkmnWormadam   = 413
	PkmnMothim     = 414
	PkmnCombee     = 415
	PkmnVespiquen  = 416
	PkmnPachirisu  = 417
	PkmnBuizel     = 418
	PkmnFloatzel   = 419
	PkmnCherubi    = 420
	PkmnCherrim    = 421
	PkmnShellos    = 422
	PkmnGastrodon  = 423
	PkmnAmbipom    = 424
	PkmnDrifloon   = 425
	PkmnDrifblim   = 426
	PkmnBuneary    = 427
	PkmnLopunny    = 428
	PkmnMismagius  = 429
	PkmnHonchkrow  = 430
	PkmnGlameow    = 431
	PkmnPurugly    = 432
	PkmnChingling  = 433
	PkmnStunky     = 434
	PkmnSkuntank   = 435
	PkmnBronzor    = 436
	PkmnBronzong   = 437
	PkmnBonsly     = 438
	PkmnMimeJr     = 439
	PkmnHappiny    = 440
	PkmnChatot     = 441
	PkmnSpiritomb  = 442
	PkmnGible      = 443
	PkmnGabite     = 444
	PkmnGarchomp   = 445
	PkmnMunchlax   = 446
	PkmnRiolu      = 447
	PkmnLucario    = 448
	PkmnHippopotas = 449
	PkmnHippowdon  = 450
	PkmnSkorupi    = 451
	PkmnDrapion    = 452
	PkmnCroagunk   = 453
	PkmnToxicroak  = 454
	PkmnCarnivine  = 455
	PkmnFinneon    = 456
	PkmnLumineon   = 457
	PkmnMantyke    = 458
	PkmnSnover     = 459
	PkmnAbomasnow  = 460
	PkmnWeavile    = 461
	PkmnMagnezone  = 462
	PkmnLickilicky = 463
	PkmnRhyperior  = 464
	PkmnTangrowth  = 465
	PkmnElectivire = 466
	PkmnMagmortar  = 467
	PkmnTogekiss   = 468
	PkmnYanmega    = 469
	PkmnLeafeon    = 470
	PkmnGlaceon    = 471
	PkmnGliscor    = 472
	PkmnMamoswine  = 473
	PkmnPorygonZ   = 474
	PkmnGallade    = 475
	PkmnProbopass  = 476
	PkmnDusknoir   = 477
	PkmnFroslass   = 478
	PkmnRotom      = 479
	PkmnUxie       = 480
	PkmnMesprit    = 481
	PkmnAzelf      = 482
	PkmnDialga     = 483
	PkmnPalkia     = 484
	PkmnHeatran    = 485
	PkmnRegigigas  = 486
	PkmnGiratina   = 487
	PkmnCresselia  = 488
	PkmnPhione     = 489
	PkmnManaphy    = 490
	PkmnDarkrai    = 491
	PkmnShaymin    = 492
	PkmnArceus     = 493
)

Pokemon const enum for quick lookup

View Source
const (
	GrowthSlow = iota + 1
	GrowthMediumFast
	GrowthFast
	GrowthMediumSlow
	GrowthErratic
	GrowthFluctuating
)

Constants for growth rates of a Pokemon

View Source
const (
	MaxFriendship = 255
	MaxEV         = 252
	MaxIV         = 31
	TotalEV       = 510
	MinLevel      = 1
	MaxLevel      = 100
)

Constants for IVs and EVs

View Source
const (
	// Base stats
	StatHP = iota
	StatAtk
	StatDef
	StatSpAtk
	StatSpDef
	StatSpeed
	// Fighting stats
	StatCritChance
	StatAccuracy
	StatEvasion
)

Constants for looking up Pokemon stats

View Source
const (
	MaxStatModifier = 6
	MinStatModifier = -6
)

The min and max number of stages that a stat can be modified is [-6, 6]

View Source
const BattleRuleSetDefault = BattleRuleFaint | BattleRuleStruggle
View Source
const MaxMoves = 4

Maximum number of moves a Pokemon can have in its moveset

View Source
const MaxPartySize = 6

Maximum number of Pokemon in a party

Variables

View Source
var AccuracyEvasionMultiplier = map[int]uint{
	-6: 300,
	-5: 266,
	-4: 250,
	-3: 200,
	-2: 166,
	-1: 133,
	0:  100,
	1:  75,
	2:  60,
	3:  50,
	4:  43,
	5:  36,
	6:  33,
}

Table for accuracy/evasion multiplier

View Source
var AllItems = []ItemData{}/* 223 elements not displayed */

A collection of all items in the game

View Source
var AllMoves = []MoveData{}/* 467 elements not displayed */
View Source
var AllPokemonData = []PokemonData{}/* 493 elements not displayed */

An array of all registered pokemon data ordered by national pokedex numbers.

View Source
var CritChances = [5]int{16, 8, 4, 3, 2}

Table of critical hit chances (denominator of 1/X)

View Source
var ErrorCannotSwitch = fmt.Errorf("cannot switch to Pokemon as it is already active or fainted\n")
View Source
var ErrorNoPP = fmt.Errorf("cannot use a move with 0 PP")
View Source
var ErrorPartyFull = fmt.Errorf("party size cannot exceed max of %d Pokemon\n", MaxPartySize)
View Source
var ErrorPartyIndex = errors.New("invalid index for party")
View Source
var ErrorValidationInvalidEvs = errors.New("Pokemon has invalid EVs.")
View Source
var ErrorValidationInvalidGender = errors.New("Pokemon has invalid gender.")
View Source
var ErrorValidationInvalidIvs = errors.New("Pokemon has invalid IVs.")
View Source
var ErrorValidationInvalidLevel = errors.New("Pokemon has invalid level.")
View Source
var ErrorValidationInvalidMoves = errors.New("Pokemon knows a move that is not allowed.")
View Source
var ErrorValidationMissingAbility = errors.New("Pokemon needs to have an ability.")
View Source
var ErrorValidationMissingMoves = errors.New("Pokemon needs at least 1 move.")
View Source
var ExpTable = map[int]map[int]int{
	GrowthSlow: {
		0:   0,
		1:   0,
		2:   10,
		3:   33,
		4:   80,
		5:   156,
		6:   270,
		7:   428,
		8:   640,
		9:   911,
		10:  1250,
		11:  1663,
		12:  2160,
		13:  2746,
		14:  3430,
		15:  4218,
		16:  5120,
		17:  6141,
		18:  7290,
		19:  8573,
		20:  10000,
		21:  11576,
		22:  13310,
		23:  15208,
		24:  17280,
		25:  19531,
		26:  21970,
		27:  24603,
		28:  27440,
		29:  30486,
		30:  33750,
		31:  37238,
		32:  40960,
		33:  44921,
		34:  49130,
		35:  53593,
		36:  58320,
		37:  63316,
		38:  68590,
		39:  74148,
		40:  80000,
		41:  86151,
		42:  92610,
		43:  99383,
		44:  106480,
		45:  113906,
		46:  121670,
		47:  129778,
		48:  138240,
		49:  147061,
		50:  156250,
		51:  165813,
		52:  175760,
		53:  186096,
		54:  196830,
		55:  207968,
		56:  219520,
		57:  231491,
		58:  243890,
		59:  256723,
		60:  270000,
		61:  283726,
		62:  297910,
		63:  312558,
		64:  327680,
		65:  343281,
		66:  359370,
		67:  375953,
		68:  393040,
		69:  410636,
		70:  428750,
		71:  447388,
		72:  466560,
		73:  486271,
		74:  506530,
		75:  527343,
		76:  548720,
		77:  570666,
		78:  593190,
		79:  616298,
		80:  640000,
		81:  664301,
		82:  689210,
		83:  714733,
		84:  740880,
		85:  767656,
		86:  795070,
		87:  823128,
		88:  851840,
		89:  881211,
		90:  911250,
		91:  941963,
		92:  973360,
		93:  1005446,
		94:  1038230,
		95:  1071718,
		96:  1105920,
		97:  1140841,
		98:  1176490,
		99:  1212873,
		100: 1250000,
	}, GrowthMediumFast: {
		0:   0,
		1:   0,
		2:   8,
		3:   27,
		4:   64,
		5:   125,
		6:   216,
		7:   343,
		8:   512,
		9:   729,
		10:  1000,
		11:  1331,
		12:  1728,
		13:  2197,
		14:  2744,
		15:  3375,
		16:  4096,
		17:  4913,
		18:  5832,
		19:  6859,
		20:  8000,
		21:  9261,
		22:  10648,
		23:  12167,
		24:  13824,
		25:  15625,
		26:  17576,
		27:  19683,
		28:  21952,
		29:  24389,
		30:  27000,
		31:  29791,
		32:  32768,
		33:  35937,
		34:  39304,
		35:  42875,
		36:  46656,
		37:  50653,
		38:  54872,
		39:  59319,
		40:  64000,
		41:  68921,
		42:  74088,
		43:  79507,
		44:  85184,
		45:  91125,
		46:  97336,
		47:  103823,
		48:  110592,
		49:  117649,
		50:  125000,
		51:  132651,
		52:  140608,
		53:  148877,
		54:  157464,
		55:  166375,
		56:  175616,
		57:  185193,
		58:  195112,
		59:  205379,
		60:  216000,
		61:  226981,
		62:  238328,
		63:  250047,
		64:  262144,
		65:  274625,
		66:  287496,
		67:  300763,
		68:  314432,
		69:  328509,
		70:  343000,
		71:  357911,
		72:  373248,
		73:  389017,
		74:  405224,
		75:  421875,
		76:  438976,
		77:  456533,
		78:  474552,
		79:  493039,
		80:  512000,
		81:  531441,
		82:  551368,
		83:  571787,
		84:  592704,
		85:  614125,
		86:  636056,
		87:  658503,
		88:  681472,
		89:  704969,
		90:  729000,
		91:  753571,
		92:  778688,
		93:  804357,
		94:  830584,
		95:  857375,
		96:  884736,
		97:  912673,
		98:  941192,
		99:  970299,
		100: 1000000,
	}, GrowthFast: {
		0:   0,
		1:   0,
		2:   6,
		3:   21,
		4:   51,
		5:   100,
		6:   172,
		7:   274,
		8:   409,
		9:   583,
		10:  800,
		11:  1064,
		12:  1382,
		13:  1757,
		14:  2195,
		15:  2700,
		16:  3276,
		17:  3930,
		18:  4665,
		19:  5487,
		20:  6400,
		21:  7408,
		22:  8518,
		23:  9733,
		24:  11059,
		25:  12500,
		26:  14060,
		27:  15746,
		28:  17561,
		29:  19511,
		30:  21600,
		31:  23832,
		32:  26214,
		33:  28749,
		34:  31443,
		35:  34300,
		36:  37324,
		37:  40522,
		38:  43897,
		39:  47455,
		40:  51200,
		41:  55136,
		42:  59270,
		43:  63605,
		44:  68147,
		45:  72900,
		46:  77868,
		47:  83058,
		48:  88473,
		49:  94119,
		50:  100000,
		51:  106120,
		52:  112486,
		53:  119101,
		54:  125971,
		55:  133100,
		56:  140492,
		57:  148154,
		58:  156089,
		59:  164303,
		60:  172800,
		61:  181584,
		62:  190662,
		63:  200037,
		64:  209715,
		65:  219700,
		66:  229996,
		67:  240610,
		68:  251545,
		69:  262807,
		70:  274400,
		71:  286328,
		72:  298598,
		73:  311213,
		74:  324179,
		75:  337500,
		76:  351180,
		77:  365226,
		78:  379641,
		79:  394431,
		80:  409600,
		81:  425152,
		82:  441094,
		83:  457429,
		84:  474163,
		85:  491300,
		86:  508844,
		87:  526802,
		88:  545177,
		89:  563975,
		90:  583200,
		91:  602856,
		92:  622950,
		93:  643485,
		94:  664467,
		95:  685900,
		96:  707788,
		97:  730138,
		98:  752953,
		99:  776239,
		100: 800000,
	}, GrowthMediumSlow: {
		0:   0,
		1:   0,
		2:   9,
		3:   57,
		4:   96,
		5:   135,
		6:   179,
		7:   236,
		8:   314,
		9:   419,
		10:  560,
		11:  742,
		12:  973,
		13:  1261,
		14:  1612,
		15:  2035,
		16:  2535,
		17:  3120,
		18:  3798,
		19:  4575,
		20:  5460,
		21:  6458,
		22:  7577,
		23:  8825,
		24:  10208,
		25:  11735,
		26:  13411,
		27:  15244,
		28:  17242,
		29:  19411,
		30:  21760,
		31:  24294,
		32:  27021,
		33:  29949,
		34:  33084,
		35:  36435,
		36:  40007,
		37:  43808,
		38:  47846,
		39:  52127,
		40:  56660,
		41:  61450,
		42:  66505,
		43:  71833,
		44:  77440,
		45:  83335,
		46:  89523,
		47:  96012,
		48:  102810,
		49:  109923,
		50:  117360,
		51:  125126,
		52:  133229,
		53:  141677,
		54:  150476,
		55:  159635,
		56:  169159,
		57:  179056,
		58:  189334,
		59:  199999,
		60:  211060,
		61:  222522,
		62:  234393,
		63:  246681,
		64:  259392,
		65:  272535,
		66:  286115,
		67:  300140,
		68:  314618,
		69:  329555,
		70:  344960,
		71:  360838,
		72:  377197,
		73:  394045,
		74:  411388,
		75:  429235,
		76:  447591,
		77:  466464,
		78:  485862,
		79:  505791,
		80:  526260,
		81:  547274,
		82:  568841,
		83:  590969,
		84:  613664,
		85:  636935,
		86:  660787,
		87:  685228,
		88:  710266,
		89:  735907,
		90:  762160,
		91:  789030,
		92:  816525,
		93:  844653,
		94:  873420,
		95:  902835,
		96:  932903,
		97:  963632,
		98:  995030,
		99:  1027103,
		100: 1059860,
	}, GrowthErratic: {
		0:   0,
		1:   0,
		2:   15,
		3:   52,
		4:   122,
		5:   237,
		6:   406,
		7:   637,
		8:   942,
		9:   1326,
		10:  1800,
		11:  2369,
		12:  3041,
		13:  3822,
		14:  4719,
		15:  5737,
		16:  6881,
		17:  8155,
		18:  9564,
		19:  11111,
		20:  12800,
		21:  14632,
		22:  16610,
		23:  18737,
		24:  21012,
		25:  23437,
		26:  26012,
		27:  28737,
		28:  31610,
		29:  34632,
		30:  37800,
		31:  41111,
		32:  44564,
		33:  48155,
		34:  51881,
		35:  55737,
		36:  59719,
		37:  63822,
		38:  68041,
		39:  72369,
		40:  76800,
		41:  81326,
		42:  85942,
		43:  90637,
		44:  95406,
		45:  100237,
		46:  105122,
		47:  110052,
		48:  115015,
		49:  120001,
		50:  125000,
		51:  131324,
		52:  137795,
		53:  144410,
		54:  151165,
		55:  158056,
		56:  165079,
		57:  172229,
		58:  179503,
		59:  186894,
		60:  194400,
		61:  202013,
		62:  209728,
		63:  217540,
		64:  225443,
		65:  233431,
		66:  241496,
		67:  249633,
		68:  257834,
		69:  267406,
		70:  276458,
		71:  286328,
		72:  296358,
		73:  305767,
		74:  316074,
		75:  326531,
		76:  336255,
		77:  346965,
		78:  357812,
		79:  367807,
		80:  378880,
		81:  390077,
		82:  400293,
		83:  411686,
		84:  423190,
		85:  433572,
		86:  445239,
		87:  457001,
		88:  467489,
		89:  479378,
		90:  491346,
		91:  501878,
		92:  513934,
		93:  526049,
		94:  536557,
		95:  548720,
		96:  560922,
		97:  571333,
		98:  583539,
		99:  591882,
		100: 600000,
	}, GrowthFluctuating: {
		0:   0,
		1:   0,
		2:   4,
		3:   13,
		4:   32,
		5:   65,
		6:   112,
		7:   178,
		8:   276,
		9:   393,
		10:  540,
		11:  745,
		12:  967,
		13:  1230,
		14:  1591,
		15:  1957,
		16:  2457,
		17:  3046,
		18:  3732,
		19:  4526,
		20:  5440,
		21:  6482,
		22:  7666,
		23:  9003,
		24:  10506,
		25:  12187,
		26:  14060,
		27:  16140,
		28:  18439,
		29:  20974,
		30:  23760,
		31:  26811,
		32:  30146,
		33:  33780,
		34:  37731,
		35:  42017,
		36:  46656,
		37:  50653,
		38:  55969,
		39:  60505,
		40:  66560,
		41:  71677,
		42:  78533,
		43:  84277,
		44:  91998,
		45:  98415,
		46:  107069,
		47:  114205,
		48:  123863,
		49:  131766,
		50:  142500,
		51:  151222,
		52:  163105,
		53:  172697,
		54:  185807,
		55:  196322,
		56:  210739,
		57:  222231,
		58:  238036,
		59:  250562,
		60:  267840,
		61:  281456,
		62:  300293,
		63:  315059,
		64:  335544,
		65:  351520,
		66:  373744,
		67:  390991,
		68:  415050,
		69:  433631,
		70:  459620,
		71:  479600,
		72:  507617,
		73:  529063,
		74:  559209,
		75:  582187,
		76:  614566,
		77:  639146,
		78:  673863,
		79:  700115,
		80:  737280,
		81:  765275,
		82:  804997,
		83:  834809,
		84:  877201,
		85:  908905,
		86:  954084,
		87:  987754,
		88:  1035837,
		89:  1071552,
		90:  1122660,
		91:  1160499,
		92:  1214753,
		93:  1254796,
		94:  1312322,
		95:  1354652,
		96:  1415577,
		97:  1460276,
		98:  1524731,
		99:  1571884,
		100: 1640000,
	}}

A table of levels mapped to the total experience at that level for each growth rate

Functions

func CalcAccuracy

func CalcAccuracy(weather Weather, user, receiver *Pokemon, move *Move) uint

Calculate the accuracy of a move, accounting for weather/evasion/held items/etc.

func CalcMoveDamage

func CalcMoveDamage(weather Weather, user, receiver *Pokemon, move *Move) (damage uint)

func GetLogger

func GetLogger() *log.Logger

Get the internal logger.

func SetLogger

func SetLogger(l *log.Logger)

Set the internal logger.

Types

type Ability

type Ability uint16
const (
	AbilityAdaptability Ability = iota + 1
	AbilityAftermath
	AbilityAirLock
	AbilityAngerPoint
	AbilityAnticipation
	AbilityArenaTrap
	AbilityBadDreams
	AbilityBattleArmor
	AbilityBlaze
	AbilityChlorophyll
	AbilityClearBody
	AbilityCloudNine
	AbilityColorChange
	AbilityCompoundEyes
	AbilityCuteCharm
	AbilityDamp
	AbilityDownload
	AbilityDrizzle
	AbilityDrought
	AbilityDrySkin
	AbilityEarlyBird
	AbilityEffectSpore
	AbilityFilter
	AbilityFlameBody
	AbilityFlashFire
	AbilityFlowerGift
	AbilityForecast
	AbilityForewarn
	AbilityFrisk
	AbilityGluttony
	AbilityGuts
	AbilityHeatproof
	AbilityHoneyGather
	AbilityHugePower
	AbilityHustle
	AbilityHydration
	AbilityHyperCutter
	AbilityIceBody
	AbilityIlluminate
	AbilityImmunity
	AbilityInnerFocus
	AbilityInsomnia
	AbilityIntimidate
	AbilityIronFist
	AbilityKeenEye
	AbilityKlutz
	AbilityLeafGuard
	AbilityLevitate
	AbilityLightningRod
	AbilityLimber
	AbilityLiquidOoze
	AbilityMagicGuard
	AbilityMagmaArmor
	AbilityMagnetPull
	AbilityMarvelScale
	AbilityMinus
	AbilityMoldBreaker
	AbilityMotorDrive
	AbilityMultitype
	AbilityNaturalCure
	AbilityNoGuard
	AbilityNormalize
	AbilityOblivious
	AbilityOvergrow
	AbilityOwnTempo
	AbilityPickup
	AbilityPlus
	AbilityPoisonHeal
	AbilityPoisonPoint
	AbilityPressure
	AbilityPurePower
	AbilityQuickFeet
	AbilityRainDish
	AbilityReckless
	AbilityRivalry
	AbilityRockHead
	AbilityRoughSkin
	AbilityRunAway
	AbilitySandStream
	AbilitySandVeil
	AbilityScrappy
	AbilitySereneGrace
	AbilityShadowTag
	AbilityShedSkin
	AbilityShellArmor
	AbilityShieldDust
	AbilitySimple
	AbilitySkillLink
	AbilitySlowStart
	AbilitySniper
	AbilitySnowCloak
	AbilitySnowWarning
	AbilitySolarPower
	AbilitySolidRock
	AbilitySoundproof
	AbilitySpeedBoost
	AbilityStall
	AbilityStatic
	AbilitySteadfast
	AbilityStench
	AbilityStickyHold
	AbilityStormDrain
	AbilitySturdy
	AbilitySuctionCups
	AbilitySuperLuck
	AbilitySwarm
	AbilitySwiftSwim
	AbilitySynchronize
	AbilityTangledFeet
	AbilityTechnician
	AbilityThickFat
	AbilityTintedLens
	AbilityTorrent
	AbilityTrace
	AbilityTruant
	AbilityUnaware
	AbilityUnburden
	AbilityVitalSpirit
	AbilityVoltAbsorb
	AbilityWaterAbsorb
	AbilityWaterVeil
	AbilityWhiteSmoke
	AbilityWonderGuard
)

func (Ability) String

func (n Ability) String() string

Get the string name of this Ability.

type Agent

type Agent interface {
	Act(ctx *BattleContext) Turn // Called for each pokemon that the agent has control over. Allowed to block for an unlimited amount of time.
}

Party agnostic interface to get turns from a human or bot. Makes turns like a Trainer or Wild Pokemon would.

type AgentTarget

type AgentTarget struct {
	Team    int     // The team that the Pokemon belongs to
	Pokemon Pokemon // Copy of Pokemon for Agents to use
	// contains filtered or unexported fields
}

func (AgentTarget) MarshalJSON

func (t AgentTarget) MarshalJSON() ([]byte, error)

func (AgentTarget) String

func (t AgentTarget) String() string

func (*AgentTarget) UnmarshalJSON

func (t *AgentTarget) UnmarshalJSON(data []byte) error

type Battle

type Battle struct {
	Weather  Weather // one of the 6 in-battle weather conditions
	ShiftSet bool    // shift or set battle style for NPC trainer battles
	State    BattleState
	Type     BattleType
	// contains filtered or unexported fields
}

A Pokemon battle. Enforces rules of the battle, and queries `Agent`s for turns.

Example
p1 := GeneratePokemon(PkmnPikachu,
	WithLevel(20),
	WithMoves(MoveThunderShock))
p2 := GeneratePokemon(PkmnBulbasaur,
	WithLevel(20),
	WithMoves(MoveTackle))
a1 := Agent(new(dumbAgent))
b := New1v1Battle(p1, &a1, p2, &a1)
b.Start()
transactions, _ := b.SimulateRound()
for _, t := range transactions {
	switch tt := t.(type) {
	case UseMoveTransaction:
		fmt.Printf("%s used %s on %s\n", b.GetPokemon(tt.User), tt.Move, b.GetPokemon(tt.Target))
	case DamageTransaction:
		fmt.Printf("%s took %d damage\n", b.GetPokemon(tt.Target), tt.Damage)
	case HealTransaction:
		fmt.Printf("%s healed for %d HP\n", b.GetPokemon(tt.Target), tt.Amount)
	case FaintTransaction:
		fmt.Printf("%s fainted\n", b.GetPokemon(tt.Target))
	case PPTransaction:
		continue
	default:
		fmt.Printf("Transaction: %T - %v\n", t, t)
	}
}
Output:

Pikachu used Thunder Shock on Bulbasaur
Bulbasaur took 6 damage
Bulbasaur used Tackle on Pikachu
Pikachu took 11 damage

func NewBattle

func NewBattle() *Battle

Creates a new battle instance, setting initial conditions

func NewBattleOfType

func NewBattleOfType(t BattleType) *Battle

Creates a new battle instance, setting initial conditions

func (*Battle) AddBattleParty

func (b *Battle) AddBattleParty(p ...*battleParty)

Adds one or more parties to a team in the battle

func (*Battle) AddParty

func (b *Battle) AddParty(p *Party, a *Agent, team int)

Add a party to the battle, controlled by an agent. This method is preferred over `AddBattleParty`.

func (*Battle) AllTargets

func (b *Battle) AllTargets() []target

Gets all the active Pokemon (targets) in the battle

func (*Battle) GetBattleContext

func (b *Battle) GetBattleContext(t target) *BattleContext

func (*Battle) GetPartiesOnTeam

func (b *Battle) GetPartiesOnTeam(team int) []*battleParty

func (*Battle) GetParty

func (b *Battle) GetParty(t target) *battleParty

Gets the battle party for a given target

func (*Battle) GetPokemon

func (b *Battle) GetPokemon(t target) *Pokemon

Gets a reference to a Pokemon from a target

func (*Battle) GetResults

func (b *Battle) GetResults() BattleResults

Get the results of the battle. The battle must be in the `BattleEnd` state.

func (*Battle) Parties

func (b *Battle) Parties() []*Party

Get the parties that are in this battle.

func (*Battle) ProcessQueue

func (b *Battle) ProcessQueue()

Process Transactions that are in the queue until the queue is empty.

func (*Battle) QueueTransaction

func (b *Battle) QueueTransaction(t ...Transaction)

Add Transactions to the queue.

func (*Battle) SetSeed

func (b *Battle) SetSeed(seed uint)

Sets the seed of the underlying random number generator used for the battle.

func (*Battle) SimulateRound

func (b *Battle) SimulateRound() ([]Transaction, bool)

Simulates a single round of the battle. Returns processed transactions for this turn and indicates whether the battle has ended.

func (*Battle) Start

func (b *Battle) Start() error

Start the battle.

type BattleContext

type BattleContext struct {
	Battle Battle // A copy of the current Battle, including weather, state, etc.
	Team   int    // The team of the acting Pokemon
	// contains filtered or unexported fields
}

func (*BattleContext) Allies

func (bc *BattleContext) Allies() []AgentTarget

func (BattleContext) MarshalJSON

func (bc BattleContext) MarshalJSON() ([]byte, error)

Custom JSON marshalling for battle context

func (*BattleContext) Opponents

func (bc *BattleContext) Opponents() []AgentTarget

func (*BattleContext) Self

func (bc *BattleContext) Self() AgentTarget

func (*BattleContext) Targets

func (bc *BattleContext) Targets() []AgentTarget

type BattleMeta

type BattleMeta int
const (
	MetaWeatherTurns BattleMeta = iota
)

type BattleResults

type BattleResults struct {
	Winner  int // The team that won the battle.
	Parties []*Party
}

Results for a Battle.

type BattleRule

type BattleRule int
const (
	BattleRuleFaint BattleRule = 1 << iota
	BattleRuleStruggle
)

type BattleState

type BattleState int
const (
	BattleBeforeStart BattleState = iota
	BattleInProgress
	BattleEnd
)

type BattleType

type BattleType int
const (
	BattleTypeSingle BattleType = iota
	BattleTypeDouble
)

func (BattleType) GetMaxActivePokemon

func (t BattleType) GetMaxActivePokemon() uint

type CureStatusTransaction

type CureStatusTransaction struct {
	Target       target
	StatusEffect StatusCondition
}

func (CureStatusTransaction) MarshalJSON

func (t CureStatusTransaction) MarshalJSON() ([]byte, error)

func (CureStatusTransaction) Mutate

func (t CureStatusTransaction) Mutate(b *Battle)

type DamageTransaction

type DamageTransaction struct {
	Target       target
	Move         *Move
	Damage       uint
	StatusEffect StatusCondition
}

A transaction to deal damage to an opponent Pokemon.

func (DamageTransaction) MarshalJSON

func (t DamageTransaction) MarshalJSON() ([]byte, error)

func (DamageTransaction) Mutate

func (t DamageTransaction) Mutate(b *Battle)

type EVTransaction

type EVTransaction struct {
	Target target
	Stat   int
	Amount uint8
}

A transaction to change the EVs of a Pokemon.

func (EVTransaction) MarshalJSON

func (t EVTransaction) MarshalJSON() ([]byte, error)

func (EVTransaction) Mutate

func (t EVTransaction) Mutate(b *Battle)

type Effectiveness

type Effectiveness int8

Represents effectiveness of an elemental type matchup.

const (
	VeryIneffective Effectiveness = iota - 2
	Ineffective
	NormalEffect
	SuperEffective
	VerySuperEffective
)
const NoEffect Effectiveness = math.MinInt8 + 1 // separate because it fucks up the iota

func GetElementalEffect

func GetElementalEffect(move, def Type) Effectiveness

Get effectiveness of a given elemental type matchup.

type EndBattleTransaction

type EndBattleTransaction struct {
	Reason EndReason
	Winner int
}

func (EndBattleTransaction) MarshalJSON

func (t EndBattleTransaction) MarshalJSON() ([]byte, error)

func (EndBattleTransaction) Mutate

func (t EndBattleTransaction) Mutate(b *Battle)

type EndReason

type EndReason int

A transaction that ends the battle.

const (
	EndKnockout EndReason = iota
	EndForfeit
	EndFlee
)

type FaintTransaction

type FaintTransaction struct {
	Target target
}

A transaction that makes a pokemon faint, and returns the pokemon to the pokeball.

func (FaintTransaction) MarshalJSON

func (t FaintTransaction) MarshalJSON() ([]byte, error)

func (FaintTransaction) Mutate

func (t FaintTransaction) Mutate(b *Battle)

type FightTurn

type FightTurn struct {
	Move   int         // Denotes the index (0-3) of the pokemon's which of the pokemon's moves to use.
	Target AgentTarget // Info containing data determining the target of
}

A turn to represent a Pokemon using a Move.

func (FightTurn) Priority

func (turn FightTurn) Priority() int

type FlingEffect

type FlingEffect uint8
const (
	FlingBadlyPoison FlingEffect = iota + 1
	FlingBurn
	FlingActivateBerry
	FlingActivateHerb
	FlingParalyze
	FlingPoison
	FlingFlinch
)

type FriendshipTransaction

type FriendshipTransaction struct {
	Target target // The target Pokemon
	Amount int    // The amount of friendship to increase/decrease
}

A transaction to change the friendship level of a Pokemon.

func (FriendshipTransaction) MarshalJSON

func (t FriendshipTransaction) MarshalJSON() ([]byte, error)

func (FriendshipTransaction) Mutate

func (t FriendshipTransaction) Mutate(b *Battle)

type Gender

type Gender uint8
const (
	GenderGenderless Gender = iota
	GenderFemale
	GenderMale
)

func RandomGender

func RandomGender(rate uint8) Gender

Get a random gender according to the gender rate.

func (Gender) String

func (g Gender) String() string

type GeneratePokemonOption

type GeneratePokemonOption func(p *Pokemon)

func WithAbility

func WithAbility(ability Ability) GeneratePokemonOption

func WithEVs

func WithEVs(evs [6]uint8) GeneratePokemonOption

func WithGender

func WithGender(g Gender) GeneratePokemonOption

func WithIVs

func WithIVs(ivs [6]uint8) GeneratePokemonOption

func WithLevel

func WithLevel(level uint8) GeneratePokemonOption

func WithMoves

func WithMoves(moves ...MoveId) GeneratePokemonOption

func WithNature

func WithNature(nature Nature) GeneratePokemonOption

func WithTotalExp

func WithTotalExp(totalExp uint) GeneratePokemonOption

type GiveItemTransaction

type GiveItemTransaction struct {
	Target target
	Item   Item
}

A transaction to change the held item of a Pokemon

func (GiveItemTransaction) MarshalJSON

func (t GiveItemTransaction) MarshalJSON() ([]byte, error)

func (GiveItemTransaction) Mutate

func (t GiveItemTransaction) Mutate(b *Battle)

type HealTransaction

type HealTransaction struct {
	Target target
	Amount uint
}

A transaction to restore HP to a Pokemon.

func (HealTransaction) MarshalJSON

func (t HealTransaction) MarshalJSON() ([]byte, error)

func (HealTransaction) Mutate

func (t HealTransaction) Mutate(b *Battle)

type ImmobilizeTransaction

type ImmobilizeTransaction struct {
	Target       target
	StatusEffect StatusCondition
}

Handles pre-turn status checks. (Paralysis, Sleeping, etc.)

func (ImmobilizeTransaction) MarshalJSON

func (t ImmobilizeTransaction) MarshalJSON() ([]byte, error)

func (ImmobilizeTransaction) Mutate

func (t ImmobilizeTransaction) Mutate(b *Battle)

type InflictStatusTransaction

type InflictStatusTransaction struct {
	Target       target
	StatusEffect StatusCondition
}

A transaction to apply a status effect to a Pokemon.

func (InflictStatusTransaction) MarshalJSON

func (t InflictStatusTransaction) MarshalJSON() ([]byte, error)

func (InflictStatusTransaction) Mutate

func (t InflictStatusTransaction) Mutate(b *Battle)

type Item

type Item uint16

A Party can use Items in a battle for different effects. A Pokemon can hold one Item.

const (
	ItemNone Item = iota
	ItemMasterBall
	ItemUltraBall
	ItemGreatBall
	ItemPokBall
	ItemSafariBall
	ItemNetBall
	ItemDiveBall
	ItemNestBall
	ItemRepeatBall
	ItemTimerBall
	ItemLuxuryBall
	ItemPremierBall
	ItemDuskBall
	ItemHealBall
	ItemQuickBall
	ItemCherishBall
	ItemPotion
	ItemAntidote
	ItemBurnHeal
	ItemIceHeal
	ItemAwakening
	ItemParalyzeHeal
	ItemFullRestore
	ItemMaxPotion
	ItemHyperPotion
	ItemSuperPotion
	ItemFullHeal
	ItemRevive
	ItemMaxRevive
	ItemFreshWater
	ItemSodaPop
	ItemLemonade
	ItemMoomooMilk
	ItemEnergyPowder
	ItemEnergyRoot
	ItemHealPowder
	ItemRevivalHerb
	ItemEther
	ItemMaxEther
	ItemElixir
	ItemMaxElixir
	ItemLavaCookie
	ItemBerryJuice
	ItemSacredAsh
	ItemHPUp
	ItemProtein
	ItemIron
	ItemCarbos
	ItemCalcium
	ItemRareCandy
	ItemPPUp
	ItemZinc
	ItemPPMax
	ItemOldGateau
	ItemGuardSpec
	ItemDireHit
	ItemXAttack
	ItemXDefense
	ItemXSpeed
	ItemXAccuracy
	ItemXSpAtk
	ItemXSpDef
	ItemPokDoll
	ItemFluffyTail
	ItemBlueFlute
	ItemYellowFlute
	ItemRedFlute
	ItemBlackFlute
	ItemWhiteFlute
	ItemAdamantOrb
	ItemLustrousOrb
	ItemCheriBerry
	ItemChestoBerry
	ItemPechaBerry
	ItemRawstBerry
	ItemAspearBerry
	ItemLeppaBerry
	ItemOranBerry
	ItemPersimBerry
	ItemLumBerry
	ItemSitrusBerry
	ItemFigyBerry
	ItemWikiBerry
	ItemMagoBerry
	ItemAguavBerry
	ItemIapapaBerry
	ItemOccaBerry
	ItemPasshoBerry
	ItemWacanBerry
	ItemRindoBerry
	ItemYacheBerry
	ItemChopleBerry
	ItemKebiaBerry
	ItemShucaBerry
	ItemCobaBerry
	ItemPayapaBerry
	ItemTangaBerry
	ItemChartiBerry
	ItemKasibBerry
	ItemHabanBerry
	ItemColburBerry
	ItemBabiriBerry
	ItemChilanBerry
	ItemLiechiBerry
	ItemGanlonBerry
	ItemSalacBerry
	ItemPetayaBerry
	ItemApicotBerry
	ItemLansatBerry
	ItemStarfBerry
	ItemEnigmaBerry
	ItemMicleBerry
	ItemCustapBerry
	ItemJabocaBerry
	ItemRowapBerry
	ItemBrightPowder
	ItemWhiteHerb
	ItemMachoBrace
	ItemExpShare
	ItemQuickClaw
	ItemSootheBell
	ItemMentalHerb
	ItemChoiceBand
	ItemKingsRock
	ItemSilverPowder
	ItemAmuletCoin
	ItemCleanseTag
	ItemSoulDew
	ItemDeepSeaTooth
	ItemDeepSeaScale
	ItemSmokeBall
	ItemEverstone
	ItemFocusBand
	ItemLuckyEgg
	ItemScopeLens
	ItemMetalCoat
	ItemLeftovers
	ItemLightBall
	ItemSoftSand
	ItemHardStone
	ItemMiracleSeed
	ItemBlackGlasses
	ItemBlackBelt
	ItemMagnet
	ItemMysticWater
	ItemSharpBeak
	ItemPoisonBarb
	ItemNeverMeltIce
	ItemSpellTag
	ItemTwistedSpoon
	ItemCharcoal
	ItemDragonFang
	ItemSilkScarf
	ItemShellBell
	ItemSeaIncense
	ItemLaxIncense
	ItemLuckyPunch
	ItemMetalPowder
	ItemThickClub
	ItemStick
	ItemRedScarf
	ItemBlueScarf
	ItemPinkScarf
	ItemGreenScarf
	ItemYellowScarf
	ItemWideLens
	ItemMuscleBand
	ItemWiseGlasses
	ItemExpertBelt
	ItemLightClay
	ItemLifeOrb
	ItemPowerHerb
	ItemToxicOrb
	ItemFlameOrb
	ItemQuickPowder
	ItemFocusSash
	ItemZoomLens
	ItemMetronome
	ItemIronBall
	ItemLaggingTail
	ItemDestinyKnot
	ItemBlackSludge
	ItemIcyRock
	ItemSmoothRock
	ItemHeatRock
	ItemDampRock
	ItemGripClaw
	ItemChoiceScarf
	ItemStickyBarb
	ItemPowerBracer
	ItemPowerBelt
	ItemPowerLens
	ItemPowerBand
	ItemPowerAnklet
	ItemPowerWeight
	ItemShedShell
	ItemBigRoot
	ItemChoiceSpecs
	ItemFlamePlate
	ItemSplashPlate
	ItemZapPlate
	ItemMeadowPlate
	ItemIciclePlate
	ItemFistPlate
	ItemToxicPlate
	ItemEarthPlate
	ItemSkyPlate
	ItemMindPlate
	ItemInsectPlate
	ItemStonePlate
	ItemSpookyPlate
	ItemDracoPlate
	ItemDreadPlate
	ItemIronPlate
	ItemOddIncense
	ItemRockIncense
	ItemFullIncense
	ItemWaveIncense
	ItemRoseIncense
	ItemLuckIncense
	ItemPureIncense
	ItemRazorClaw
	ItemRazorFang
)

Item constants for quick and easy reference

func (Item) Category

func (i Item) Category() ItemCategory

func (Item) Data

func (i Item) Data() *ItemData

Retrieves an Item's data. For item effects, see https://github.com/veekun/pokedex/blob/master/pokedex/data/csv/item_prose.csv

func (Item) Flags

func (i Item) Flags() ItemFlags

func (Item) FlingEffect

func (i Item) FlingEffect() FlingEffect

func (Item) FlingPower

func (i Item) FlingPower() int

func (Item) MarshalJSON

func (i Item) MarshalJSON() ([]byte, error)

func (Item) Name

func (i Item) Name() string

func (*Item) UnmarshalJSON

func (i *Item) UnmarshalJSON(data []byte) error

type ItemCategory

type ItemCategory uint8

type ItemData

type ItemData struct {
	Name        string
	Category    ItemCategory
	FlingPower  int
	FlingEffect FlingEffect
	Flags       ItemFlags
}

Represents data associated with an `Item`.

type ItemFlags

type ItemFlags uint8

Properties that an item can have.

const (
	// The item can be consumed
	FlagConsumable ItemFlags = 1 << iota
	// The item can be held by a pokemon
	FlagHoldable
	// The item has passive effects when held.
	FlagHoldablePassive
	// The item can be used by a pokemon when held.
	FlagHoldableActive
	// The item can be used in battle
	FlagUsableInBattle
)

type ItemTransaction

type ItemTransaction struct {
	Target target
	IsHeld bool
	Item   Item
	Move   *Move
}

A transaction to use and possibly consume an item.

func (ItemTransaction) MarshalJSON

func (t ItemTransaction) MarshalJSON() ([]byte, error)

func (ItemTransaction) Mutate

func (t ItemTransaction) Mutate(b *Battle)

type ItemTurn

type ItemTurn struct {
	Move   int         // Denotes the index (0-3) of the pokemon's which of the pokemon's moves to use.
	Target AgentTarget // Info containing data determining the target of
	Item   Item        // Which item is being consumed
}

A turn to represent using an item from the Party's inventory. An item turn has the a higher priority than any move.

func (ItemTurn) Priority

func (turn ItemTurn) Priority() int

type LCRNG

type LCRNG uint32

Implements the LCRNG algorithm used by the original Pokemon Diamond/Pearl, and all other mainline Pokemon games that released on the GBA/DS. Note that this type must only be used in pointer form.

func (*LCRNG) Get

func (g *LCRNG) Get(min, max int) int

func (*LCRNG) Roll

func (g *LCRNG) Roll(x, y int) bool

Rolls for a x/y chance, returning whether it was hit

func (*LCRNG) SetSeed

func (g *LCRNG) SetSeed(seed uint)

type ModifyStatTransaction

type ModifyStatTransaction struct {
	Target        target
	SelfInflicted bool
	Stat          int
	Stages        int
}

Modifies a stat's stages in the interval [-6, 6]

func (ModifyStatTransaction) MarshalJSON

func (t ModifyStatTransaction) MarshalJSON() ([]byte, error)

func (ModifyStatTransaction) Mutate

func (t ModifyStatTransaction) Mutate(b *Battle)

type Move

type Move struct {
	Id        MoveId
	CurrentPP uint8
	MaxPP     uint8
}

Represents a Pokemon's move. Moves can deal damage, heal the user or allies, or cause status effects.

func GetMove

func GetMove(id MoveId) *Move

Retrieves a Pokemon move given its move ID

func (Move) Accuracy

func (m Move) Accuracy() uint

func (Move) AffectedStat

func (m Move) AffectedStat() uint8

func (Move) Ailment

func (m Move) Ailment() StatusCondition

func (Move) AilmentChance

func (m Move) AilmentChance() int

func (Move) Category

func (m Move) Category() MoveCategory

func (Move) CritRate

func (m Move) CritRate() int

func (*Move) Data

func (m *Move) Data() *MoveData

Grabs move's constant data

func (Move) Drain

func (m Move) Drain() int

func (Move) Flags

func (m Move) Flags() MoveFlags

func (Move) FlinchChance

func (m Move) FlinchChance() int

func (Move) Healing

func (m Move) Healing() int

func (Move) InitialMaxPP

func (m Move) InitialMaxPP() uint8

func (*Move) MarshalJSON

func (m *Move) MarshalJSON() ([]byte, error)

func (Move) MaxHits

func (m Move) MaxHits() int

func (Move) MaxTurns

func (m Move) MaxTurns() int

func (Move) MetaCategory

func (m Move) MetaCategory() MoveMetaCategory

func (Move) MinHits

func (m Move) MinHits() int

func (Move) MinTurns

func (m Move) MinTurns() int

func (Move) Name

func (m Move) Name() string

func (Move) Power

func (m Move) Power() uint

func (Move) Priority

func (m Move) Priority() int8

func (Move) StatChance

func (m Move) StatChance() int

func (Move) StatStages

func (m Move) StatStages() int8

func (Move) String

func (m Move) String() string

func (Move) Targets

func (m Move) Targets() MoveTarget

func (Move) Type

func (m Move) Type() Type

func (*Move) UnmarshalJSON

func (m *Move) UnmarshalJSON(data []byte) error

type MoveCategory

type MoveCategory uint8
const (
	MoveCategoryStatus MoveCategory = iota
	MoveCategoryPhysical
	MoveCategorySpecial
)

func (MoveCategory) String

func (c MoveCategory) String() string

type MoveData

type MoveData struct {
	Name         string
	Type         Type
	Category     MoveCategory
	Targets      MoveTarget
	Priority     int8
	Power        uint
	Accuracy     uint
	InitialMaxPP uint8
	// Metadata
	MinHits       int
	MaxHits       int
	MinTurns      int
	MaxTurns      int
	Drain         int // Percentage (out of 100) of the damage dealt by this move is given back to the user as HP. If the value is negative, it's recoil damage.
	Healing       int
	CritRate      int
	AilmentChance int
	FlinchChance  int
	StatChance    int
	Flags         MoveFlags
	AffectedStat  uint8 // if this move modifies stats, this is the stat it modifies
	StatStages    int8  // if 0, then this move does not modify stats
	Ailment       StatusCondition
	MetaCategory  MoveMetaCategory
}

type MoveFailReason

type MoveFailReason uint8
const (
	FailOther MoveFailReason = iota
	FailMiss
	FailDodge
)

type MoveFailTransaction

type MoveFailTransaction struct {
	User   target
	Reason MoveFailReason
}

Handles evasion, misses, dodging, etc. when using moves

func (MoveFailTransaction) MarshalJSON

func (t MoveFailTransaction) MarshalJSON() ([]byte, error)

func (MoveFailTransaction) Mutate

func (t MoveFailTransaction) Mutate(b *Battle)

type MoveFlags

type MoveFlags uint32
const (
	// This move ignores the target's Substitute.
	FlagAuthentic MoveFlags = 1 << iota
	// This move is blocked by Bulletproof.
	FlagBallistics
	// This move has 1.5× its usual power when used by a Pokémon with Strong Jaw.
	FlagBite
	// This move has a charging turn that can be skipped with a Power Herb.
	FlagCharge
	// User touches the target. This triggers some abilities (e.g., Static) and items (e.g., Sticky Barb).
	FlagContact
	// This move triggers the ability Dancer.
	FlagDance
	// This move can be used while frozen to force the Pokémon to defrost.
	FlagDefrost
	// In triple battles, this move can be used on either side to target the farthest away opposing Pokémon. (non gen 4)
	FlagDistance
	// This move cannot be used in high Gravity.
	FlagGravity
	// This move is blocked by Heal Block.
	FlagHeal
	// This move is blocked by Aroma Veil and cured by Mental Herb.
	FlagMental
	// Copied by Mirror Move: A Pokémon targeted by this move can use Mirror Move to copy it.
	FlagMirror
	// Not usable in sky battles (non gen 4)
	FlagNonSkyBattle
	// Pokémon with Overcoat and Grass-type Pokémon are immune to this move.
	FlagPowder
	// This move will not work if the target has used Detect or Protect this turn.
	FlagProtect
	// This move has 1.5× its usual power when used by a Pokémon with Mega Launcher. (non gen 4)
	FlagPulse
	// This move has 1.2× its usual power when used by a Pokémon with Iron Fist.
	FlagPunch
	// The turn after this move is used, the Pokémon's action is skipped so it can recharge.
	FlagRecharge
	// This move may be reflected back at the user with Magic Coat or Magic Bounce.
	FlagReflectable
	// This move will be stolen if another Pokémon has used Snatch this turn.
	FlagSnatch
	// Pokémon with Soundproof are immune to this move.
	FlagSound
)

type MoveId

type MoveId uint16
const (
	MoveNone MoveId = iota
	MovePound
	MoveKarateChop
	MoveDoubleSlap
	MoveCometPunch
	MoveMegaPunch
	MovePayDay
	MoveFirePunch
	MoveIcePunch
	MoveThunderPunch
	MoveScratch
	MoveViceGrip
	MoveGuillotine
	MoveRazorWind
	MoveSwordsDance
	MoveCut
	MoveGust
	MoveWingAttack
	MoveWhirlwind
	MoveFly
	MoveBind
	MoveSlam
	MoveVineWhip
	MoveStomp
	MoveDoubleKick
	MoveMegaKick
	MoveJumpKick
	MoveRollingKick
	MoveSandAttack
	MoveHeadbutt
	MoveHornAttack
	MoveFuryAttack
	MoveHornDrill
	MoveTackle
	MoveBodySlam
	MoveWrap
	MoveTakeDown
	MoveThrash
	MoveDoubleEdge
	MoveTailWhip
	MovePoisonSting
	MoveTwineedle
	MovePinMissile
	MoveLeer
	MoveBite
	MoveGrowl
	MoveRoar
	MoveSing
	MoveSupersonic
	MoveSonicBoom
	MoveDisable
	MoveAcid
	MoveEmber
	MoveFlamethrower
	MoveMist
	MoveWaterGun
	MoveHydroPump
	MoveSurf
	MoveIceBeam
	MoveBlizzard
	MovePsybeam
	MoveBubbleBeam
	MoveAuroraBeam
	MoveHyperBeam
	MovePeck
	MoveDrillPeck
	MoveSubmission
	MoveLowKick
	MoveCounter
	MoveSeismicToss
	MoveStrength
	MoveAbsorb
	MoveMegaDrain
	MoveLeechSeed
	MoveGrowth
	MoveRazorLeaf
	MoveSolarBeam
	MovePoisonPowder
	MoveStunSpore
	MoveSleepPowder
	MovePetalDance
	MoveStringShot
	MoveDragonRage
	MoveFireSpin
	MoveThunderShock
	MoveThunderbolt
	MoveThunderWave
	MoveThunder
	MoveRockThrow
	MoveEarthquake
	MoveFissure
	MoveDig
	MoveToxic
	MoveConfusion
	MovePsychic
	MoveHypnosis
	MoveMeditate
	MoveAgility
	MoveQuickAttack
	MoveRage
	MoveTeleport
	MoveNightShade
	MoveMimic
	MoveScreech
	MoveDoubleTeam
	MoveRecover
	MoveHarden
	MoveMinimize
	MoveSmokescreen
	MoveConfuseRay
	MoveWithdraw
	MoveDefenseCurl
	MoveBarrier
	MoveLightScreen
	MoveHaze
	MoveReflect
	MoveFocusEnergy
	MoveBide
	MoveMetronome
	MoveMirrorMove
	MoveSelfDestruct
	MoveEggBomb
	MoveLick
	MoveSmog
	MoveSludge
	MoveBoneClub
	MoveFireBlast
	MoveWaterfall
	MoveClamp
	MoveSwift
	MoveSkullBash
	MoveSpikeCannon
	MoveConstrict
	MoveAmnesia
	MoveKinesis
	MoveSoftBoiled
	MoveHighJumpKick
	MoveGlare
	MoveDreamEater
	MovePoisonGas
	MoveBarrage
	MoveLeechLife
	MoveLovelyKiss
	MoveSkyAttack
	MoveTransform
	MoveBubble
	MoveDizzyPunch
	MoveSpore
	MoveFlash
	MovePsywave
	MoveSplash
	MoveAcidArmor
	MoveCrabhammer
	MoveExplosion
	MoveFurySwipes
	MoveBonemerang
	MoveRest
	MoveRockSlide
	MoveHyperFang
	MoveSharpen
	MoveConversion
	MoveTriAttack
	MoveSuperFang
	MoveSlash
	MoveSubstitute
	MoveStruggle
	MoveSketch
	MoveTripleKick
	MoveThief
	MoveSpiderWeb
	MoveMindReader
	MoveNightmare
	MoveFlameWheel
	MoveSnore
	MoveCurse
	MoveFlail
	MoveConversion2
	MoveAeroblast
	MoveCottonSpore
	MoveReversal
	MoveSpite
	MovePowderSnow
	MoveProtect
	MoveMachPunch
	MoveScaryFace
	MoveFeintAttack
	MoveSweetKiss
	MoveBellyDrum
	MoveSludgeBomb
	MoveMudSlap
	MoveOctazooka
	MoveSpikes
	MoveZapCannon
	MoveForesight
	MoveDestinyBond
	MovePerishSong
	MoveIcyWind
	MoveDetect
	MoveBoneRush
	MoveLockOn
	MoveOutrage
	MoveSandstorm
	MoveGigaDrain
	MoveEndure
	MoveCharm
	MoveRollout
	MoveFalseSwipe
	MoveSwagger
	MoveMilkDrink
	MoveSpark
	MoveFuryCutter
	MoveSteelWing
	MoveMeanLook
	MoveAttract
	MoveSleepTalk
	MoveHealBell
	MoveReturn
	MovePresent
	MoveFrustration
	MoveSafeguard
	MovePainSplit
	MoveSacredFire
	MoveMagnitude
	MoveDynamicPunch
	MoveMegahorn
	MoveDragonBreath
	MoveBatonPass
	MoveEncore
	MovePursuit
	MoveRapidSpin
	MoveSweetScent
	MoveIronTail
	MoveMetalClaw
	MoveVitalThrow
	MoveMorningSun
	MoveSynthesis
	MoveMoonlight
	MoveHiddenPower
	MoveCrossChop
	MoveTwister
	MoveRainDance
	MoveSunnyDay
	MoveCrunch
	MoveMirrorCoat
	MovePsychUp
	MoveExtremeSpeed
	MoveAncientPower
	MoveShadowBall
	MoveFutureSight
	MoveRockSmash
	MoveWhirlpool
	MoveBeatUp
	MoveFakeOut
	MoveUproar
	MoveStockpile
	MoveSpitUp
	MoveSwallow
	MoveHeatWave
	MoveHail
	MoveTorment
	MoveFlatter
	MoveWillOWisp
	MoveMemento
	MoveFacade
	MoveFocusPunch
	MoveSmellingSalts
	MoveFollowMe
	MoveNaturePower
	MoveCharge
	MoveTaunt
	MoveHelpingHand
	MoveTrick
	MoveRolePlay
	MoveWish
	MoveAssist
	MoveIngrain
	MoveSuperpower
	MoveMagicCoat
	MoveRecycle
	MoveRevenge
	MoveBrickBreak
	MoveYawn
	MoveKnockOff
	MoveEndeavor
	MoveEruption
	MoveSkillSwap
	MoveImprison
	MoveRefresh
	MoveGrudge
	MoveSnatch
	MoveSecretPower
	MoveDive
	MoveArmThrust
	MoveCamouflage
	MoveTailGlow
	MoveLusterPurge
	MoveMistBall
	MoveFeatherDance
	MoveTeeterDance
	MoveBlazeKick
	MoveMudSport
	MoveIceBall
	MoveNeedleArm
	MoveSlackOff
	MoveHyperVoice
	MovePoisonFang
	MoveCrushClaw
	MoveBlastBurn
	MoveHydroCannon
	MoveMeteorMash
	MoveAstonish
	MoveWeatherBall
	MoveAromatherapy
	MoveFakeTears
	MoveAirCutter
	MoveOverheat
	MoveOdorSleuth
	MoveRockTomb
	MoveSilverWind
	MoveMetalSound
	MoveGrassWhistle
	MoveTickle
	MoveCosmicPower
	MoveWaterSpout
	MoveSignalBeam
	MoveShadowPunch
	MoveExtrasensory
	MoveSkyUppercut
	MoveSandTomb
	MoveSheerCold
	MoveMuddyWater
	MoveBulletSeed
	MoveAerialAce
	MoveIcicleSpear
	MoveIronDefense
	MoveBlock
	MoveHowl
	MoveDragonClaw
	MoveFrenzyPlant
	MoveBulkUp
	MoveBounce
	MoveMudShot
	MovePoisonTail
	MoveCovet
	MoveVoltTackle
	MoveMagicalLeaf
	MoveWaterSport
	MoveCalmMind
	MoveLeafBlade
	MoveDragonDance
	MoveRockBlast
	MoveShockWave
	MoveWaterPulse
	MoveDoomDesire
	MovePsychoBoost
	MoveRoost
	MoveGravity
	MoveMiracleEye
	MoveWakeUpSlap
	MoveHammerArm
	MoveGyroBall
	MoveHealingWish
	MoveBrine
	MoveNaturalGift
	MoveFeint
	MovePluck
	MoveTailwind
	MoveAcupressure
	MoveMetalBurst
	MoveUturn
	MoveCloseCombat
	MovePayback
	MoveAssurance
	MoveEmbargo
	MoveFling
	MovePsychoShift
	MoveTrumpCard
	MoveHealBlock
	MoveWringOut
	MovePowerTrick
	MoveGastroAcid
	MoveLuckyChant
	MoveMeFirst
	MoveCopycat
	MovePowerSwap
	MoveGuardSwap
	MovePunishment
	MoveLastResort
	MoveWorrySeed
	MoveSuckerPunch
	MoveToxicSpikes
	MoveHeartSwap
	MoveAquaRing
	MoveMagnetRise
	MoveFlareBlitz
	MoveForcePalm
	MoveAuraSphere
	MoveRockPolish
	MovePoisonJab
	MoveDarkPulse
	MoveNightSlash
	MoveAquaTail
	MoveSeedBomb
	MoveAirSlash
	MoveXScissor
	MoveBugBuzz
	MoveDragonPulse
	MoveDragonRush
	MovePowerGem
	MoveDrainPunch
	MoveVacuumWave
	MoveFocusBlast
	MoveEnergyBall
	MoveBraveBird
	MoveEarthPower
	MoveSwitcheroo
	MoveGigaImpact
	MoveNastyPlot
	MoveBulletPunch
	MoveAvalanche
	MoveIceShard
	MoveShadowClaw
	MoveThunderFang
	MoveIceFang
	MoveFireFang
	MoveShadowSneak
	MoveMudBomb
	MovePsychoCut
	MoveZenHeadbutt
	MoveMirrorShot
	MoveFlashCannon
	MoveRockClimb
	MoveDefog
	MoveTrickRoom
	MoveDracoMeteor
	MoveDischarge
	MoveLavaPlume
	MoveLeafStorm
	MovePowerWhip
	MoveRockWrecker
	MoveCrossPoison
	MoveGunkShot
	MoveIronHead
	MoveMagnetBomb
	MoveStoneEdge
	MoveCaptivate
	MoveStealthRock
	MoveGrassKnot
	MoveChatter
	MoveJudgment
	MoveBugBite
	MoveChargeBeam
	MoveWoodHammer
	MoveAquaJet
	MoveAttackOrder
	MoveDefendOrder
	MoveHealOrder
	MoveHeadSmash
	MoveDoubleHit
	MoveRoarofTime
	MoveSpacialRend
	MoveLunarDance
	MoveCrushGrip
	MoveMagmaStorm
	MoveDarkVoid
	MoveSeedFlare
	MoveOminousWind
	MoveShadowForce
)

Move constants for quick and easy reference

func RegisterMove

func RegisterMove(data MoveData) MoveId

Creates a new move and returns the ID of the move created

type MoveMetaCategory

type MoveMetaCategory uint8

Helps define the bahavior of moves.

const (
	MoveMetaCategoryDamage           MoveMetaCategory = iota // Deal damage to target pokemon.
	MoveMetaCategoryAilment                                  // Apply a status condition to the target of the move.
	MoveMetaCategoryNetGoodStats                             // Modify the target pokemon's stats.
	MoveMetaCategoryHeal                                     // Heals the user or a target ally.
	MoveMetaCategoryDamageAilment                            // Deal damage to target pokemon, and have a chance to apply a status condition to the target of the move.
	MoveMetaCategorySwagger                                  // Raise the target's stats, and apply confusion.
	MoveMetaCategoryDamageLower                              // Deal damage to target pokemon, and have a chance to apply a stat modifier to the target of the move.
	MoveMetaCategoryDamageRaise                              // Deal damage to target pokemon, and have a chance to apply a stat modifier to the user of the move.
	MoveMetaCategoryDamageHeal                               // Deal damage to target pokemon, and restore some of the user's HP. However, this is effectively a noop, because this functionality is only present on moves that have `Drain != 0`.
	MoveMetaCategoryOhko                                     // One hit knock out. If the move hits the target pokemon, it is generally guaranteed to die (there are exceptions). Always fails if the target pokemon's level is greater than the user's level.
	MoveMetaCategoryWholeFieldEffect                         // Applies a special effect to the entire battlefield (usually weather).
	MoveMetaCategoryFieldEffect                              // Applies a special effect to the user's side of the battlefield.
	MoveMetaCategoryForceSwitch                              // Forces the target pokemon to switch out.
	MoveMetaCategoryUnique                                   // For moves that have specific, one-off rules.
)

type MoveTarget

type MoveTarget uint8

Targets that the move can specify

const (
	MoveTargetSpecificMove MoveTarget = iota + 1
	MoveTargetSelectedMeFirst
	MoveTargetAlly
	MoveTargetUsersField
	MoveTargetUserOrAlly
	MoveTargetOpponentsField
	MoveTargetUser
	MoveTargetRandomOpponent
	MoveTargetAllOthers
	MoveTargetSelected
	MoveTargetAllOpponents
	MoveTargetEntireField
	MoveTargetUserAndAllies
	MoveTargetAll
)

type Nature

type Nature uint8

Natures can affect a Pokemon's stats, increasing one and decreasing another. *Constants, GetStatModifiers(), and String() are auto-generated.*

const (
	NatureAdamant Nature = iota
	NatureBashful
	NatureBold
	NatureBrave
	NatureCalm
	NatureCareful
	NatureDocile
	NatureGentle
	NatureHardy
	NatureHasty
	NatureImpish
	NatureJolly
	NatureLax
	NatureLonely
	NatureMild
	NatureModest
	NatureNaive
	NatureNaughty
	NatureQuiet
	NatureQuirky
	NatureRash
	NatureRelaxed
	NatureSassy
	NatureSerious
	NatureTimid
)

func (Nature) GetStatModifiers

func (n Nature) GetStatModifiers() (statUp, statDown int)

Get the stat modifiers that this nature gives.

func (Nature) String

func (n Nature) String() string

Get the string name of this Nature.

type PPTransaction

type PPTransaction struct {
	Move   *Move
	Amount int8
}

A transaction to change the PP of a move.

func (PPTransaction) MarshalJSON

func (t PPTransaction) MarshalJSON() ([]byte, error)

func (PPTransaction) Mutate

func (t PPTransaction) Mutate(b *Battle)

type Party

type Party struct {
	Pokemon      []*Pokemon
	PokemonRules PokemonValidationRules
}

A Party of Pokemon.

Example
party := NewParty()
err := party.AddPokemon(
	GeneratePokemon(PkmnPikachu, WithMoves(MoveGrowl)),
	GeneratePokemon(PkmnCharizard, WithMoves(MoveGrowl)),
)
if err != nil {
	fmt.Print(err)
	return
}
for _, p := range party.Pokemon {
	fmt.Printf("%s\n", p)
}
Output:

Pikachu
Charizard

func NewOccupiedParty

func NewOccupiedParty(pkmn ...*Pokemon) *Party

func NewParty

func NewParty() *Party

func (*Party) AddPokemon

func (p *Party) AddPokemon(pkmn ...*Pokemon) error

Adds 1 or more Pokemon to a Party

type Pokemon

type Pokemon struct {
	NatDex            uint16          // National Pokedex Number
	Level             uint8           // value from 1-100 influencing stats
	Ability           Ability         // name of this Pokemon's ability
	TotalExperience   uint            // the total amount of exp this Pokemon has gained, influencing its level
	Gender            Gender          // this Pokemon's gender
	IVs               [6]uint8        // values from 0-31 that represents a Pokemon's 'genetic' potential
	EVs               [6]uint8        // values from 0-255 that represents a Pokemon's training in a particular stat
	Nature            Nature          // represents a Pokemon's disposition and affects stats
	Stats             [6]uint         // the actual stats of a Pokemon determined from the above data
	StatModifiers     [9]int          // ranges from +6 (buffing) to -6 (debuffing) a stat
	StatusEffects     StatusCondition // the current status effects inflicted on a Pokemon
	CurrentHP         uint            // the remaining HP of this Pokemon
	HeldItem          Item            // the item a Pokemon is holding
	Moves             [MaxMoves]*Move // the moves the Pokemon currenly knows
	Friendship        int             // how close this Pokemon is to its Trainer
	OriginalTrainerID uint16          // a number associated with the first Trainer who caught this Pokemon
	Type              Type            // Indicates what type(s) (up to 2 simultaneously) this pokemon has
	// contains filtered or unexported fields
}

func GeneratePokemon

func GeneratePokemon(natdex int, opts ...GeneratePokemonOption) *Pokemon

Creates a new Pokemon given its national dex number and other options.

Example
pkmn := GeneratePokemon(PkmnPikachu,
	WithLevel(28),
	WithMoves(MoveThunderShock, MoveIronTail, MoveTailWhip, MoveVoltTackle),
)
fmt.Printf("%s\n", pkmn)
fmt.Printf("%s\n", pkmn.Moves)
Output:

Pikachu
[Thunder Shock Iron Tail Tail Whip Volt Tackle]

func (*Pokemon) Accuracy

func (p *Pokemon) Accuracy() uint

Returns multiplier for accuracy

func (*Pokemon) Attack

func (p *Pokemon) Attack() uint

func (*Pokemon) CritChance

func (p *Pokemon) CritChance() int

Returns denominator for critical hit chance

func (*Pokemon) Data

func (p *Pokemon) Data() PokemonData

func (*Pokemon) Defense

func (p *Pokemon) Defense() uint

func (*Pokemon) EffectiveType

func (p *Pokemon) EffectiveType() Type

Get the Pokemon's current elemental type, accounting for any abilities or conditions that would affect it.

func (*Pokemon) Evasion

func (p *Pokemon) Evasion() uint

Returns multiplier for evasion

func (*Pokemon) GainExperience

func (p *Pokemon) GainExperience(exp int)

Increases a Pokemon's experience points by `exp` and levels up the Pokemon accordingly.

func (*Pokemon) GainLevels

func (p *Pokemon) GainLevels(levels int)

Increases a Pokemon's level by `levels` and sets their total experience to the minimum amount for that level.

func (*Pokemon) GetBaseStats

func (p *Pokemon) GetBaseStats() [6]int

func (*Pokemon) GetEVYield

func (p *Pokemon) GetEVYield() [6]int

func (*Pokemon) GetGrowthRate

func (p *Pokemon) GetGrowthRate() int

func (*Pokemon) GetName

func (p *Pokemon) GetName() string

func (*Pokemon) HasValidEVs

func (p *Pokemon) HasValidEVs() bool

func (*Pokemon) HasValidIVs

func (p *Pokemon) HasValidIVs() bool

func (*Pokemon) HasValidLevel

func (p *Pokemon) HasValidLevel() bool

func (*Pokemon) IsGrounded

func (p *Pokemon) IsGrounded() bool

Check if the Pokemon is grounded

func (*Pokemon) MarshalJSON

func (p *Pokemon) MarshalJSON() ([]byte, error)

func (*Pokemon) MaxHP

func (p *Pokemon) MaxHP() uint

Stat getters return the effective stat values from modifiers

func (*Pokemon) SpecialAttack

func (p *Pokemon) SpecialAttack() uint

func (*Pokemon) SpecialDefense

func (p *Pokemon) SpecialDefense() uint

func (*Pokemon) Speed

func (p *Pokemon) Speed() uint

func (Pokemon) String

func (p Pokemon) String() string

display a Pokemon close to how it would appear in a Pokemon battle

func (*Pokemon) UnmarshalJSON

func (p *Pokemon) UnmarshalJSON(data []byte) error

func (*Pokemon) Validate

func (p *Pokemon) Validate(rules PokemonValidationRules) error

type PokemonData

type PokemonData struct {
	NatDex            uint16
	Name              string
	Type              Type
	Ability           Ability
	BaseStats         [6]int // base stats of a Pokemon
	EvYield           [6]int // effort points gained when Pokemon is defeated
	GrowthRate        int
	IsBiGender        bool  // true if this Pokemon must have `Male` or `Female`, false if this Pokemon must be `Genderless`
	GenderRate        uint8 // Female to Male ratio. This number is used to create the ratio `GenderRate` : 8 - `GenderRate`. 0 is always male, 8 is always female.
	HasAlternateForms bool
	IsLegendary       bool
	IsMythical        bool
	EvolvesFrom       uint16 // If zero, then this pokemon does not evolve from another Pokemon.
}

type PokemonMeta

type PokemonMeta int

Metadata for a Pokemon to keep track of

const (
	MetaLastItem PokemonMeta = iota
	MetaLastMove
	MetaSleepTime
	MetaStatChangeImmune
)

type PokemonValidationRules

type PokemonValidationRules uint8

Used to pick and choose which validation rules to enforce

const (
	PkmnRuleHasMoves PokemonValidationRules = 1 << iota
	PkmnRuleHasAbility
	PkmnRuleValidLevel
	PkmnRuleValidIvs
	PkmnRuleValidEvs
	PkmnRuleValidGender
	// Pokemon are not allowed to know the move struggle.
	PkmnRuleNoStruggle
)

type RNG

type RNG interface {
	SetSeed(seed uint)
	Get(min, max int) int // Get a random number.
	Roll(x, y int) bool   // Generate a random boolean with a probability of x/y. Returns true x out of y times.
}

Provides an interface for generating pseudo random numbers.

type SendOutTransaction

type SendOutTransaction struct {
	Target target
}

A transaction that makes a party send out a pokemon.

func (SendOutTransaction) MarshalJSON

func (t SendOutTransaction) MarshalJSON() ([]byte, error)

func (SendOutTransaction) Mutate

func (t SendOutTransaction) Mutate(b *Battle)

type StatusCondition

type StatusCondition uint32

Represents volatile and non-volatile status conditions on a pokemon.

const (
	StatusNone StatusCondition = 0

	// Non volatile - first 3 bits
	StatusBurn StatusCondition = iota
	StatusFreeze
	StatusParalyze
	StatusPoison
	StatusBadlyPoison
	StatusSleep
)
const (
	// volatile - the rest of the bits
	StatusBound StatusCondition = 1 << (iota + 3)
	StatusCantEscape
	StatusConfusion
	StatusCursed
	StatusEmbargo
	StatusFlinch
	StatusHealBlock
	StatusIdentified
	StatusInfatuation
	StatusLeechSeed
	StatusNightmare
	StatusPerishSong
	StatusTaunt
	StatusTorment
)
const (
	StatusNonvolatileMask StatusCondition = 0b111
	StatusVolatileMask    StatusCondition = math.MaxUint32 ^ StatusNonvolatileMask
)

func (StatusCondition) String

func (s StatusCondition) String() string

type SwitchTurn

type SwitchTurn struct {
	Target AgentTarget // The target to swap to
}

A turn to represent switching an active Pokemon for a different, inactive Pokemon in battle.

func (SwitchTurn) Priority

func (turn SwitchTurn) Priority() int

type Transaction

type Transaction interface {
	Mutate(b *Battle) // Modifies the battle to apply the transaction. Can also queue additional transactions via b.QueueTransaction().
}

Transactions describes a change to battle state. A sequence of transactions should be able to describe an entire battle.

type Turn

type Turn interface {
	Priority() int // Gets the turn's priority. Higher values go first. Not to be confused with Move priority.
}

An abstraction over all possible actions an `Agent` can make in one round. Each Pokemon gets one turn.

type TurnContext

type TurnContext struct {
	User target // The pokemon that made this turn.
	Turn Turn   // A copy of the turn that a Pokemon made using an Agent
}

Wrapper used to determine turn order in a battle

type Type

type Type uint32

Represents a bit mask of all elemental types

const (
	TypeNormal Type = 1 << iota
	TypeFighting
	TypeFlying
	TypePoison
	TypeGround
	TypeRock
	TypeBug
	TypeGhost
	TypeSteel
	TypeFire
	TypeWater
	TypeGrass
	TypeElectric
	TypePsychic
	TypeIce
	TypeDragon
	TypeDark
)

func (Type) String

func (t Type) String() string

type UseMoveTransaction

type UseMoveTransaction struct {
	User   target
	Target target
	Move   *Move
}

func (UseMoveTransaction) MarshalJSON

func (t UseMoveTransaction) MarshalJSON() ([]byte, error)

func (UseMoveTransaction) Mutate

func (t UseMoveTransaction) Mutate(b *Battle)

type Weather

type Weather int

Weather effects

const (
	WeatherClearSkies Weather = iota
	WeatherHarshSunlight
	WeatherRain
	WeatherSandstorm
	WeatherHail
	WeatherFog
)

type WeatherTransaction

type WeatherTransaction struct {
	Weather Weather
	Turns   int
}

Changes the current weather in a battle

func (WeatherTransaction) MarshalJSON

func (t WeatherTransaction) MarshalJSON() ([]byte, error)

func (WeatherTransaction) Mutate

func (t WeatherTransaction) Mutate(b *Battle)

Directories

Path Synopsis
scripts
getters
Auto generate getters on one type to grab data from another type.
Auto generate getters on one type to grab data from another type.
transaction_marshall
Auto generate MarshallJSON on all transactions.
Auto generate MarshallJSON on all transactions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL