StevensSEC / pokemonbattlelib

A portable library for accurately simulating Pokemon battles.
GNU General Public License v3.0
13 stars 2 forks source link

Snapshot Testing #226

Open adapap opened 3 years ago

adapap commented 3 years ago

To quickly debug hundreds, or thousands of random battles, we need a way to quickly capture the results of part or entire battle. The best way to do this is to create a string representation of the battle, which can double up as output to be read by the end user.

This is what I had in mind:

b.createSnapshot(p *party) string {
  // Party changes the wording to be from the perspective of a specific party
  // E.g. "CHARMANDER used Tackle!" vs. "The foe's CHARMANDER used Tackle!"
  // logic...
  return snapshot

Example output:

What will CHARMANDER do?
CHARMANDER used Tackle!
Critical hit!
The foe's RATTATA fainted!
CHARMANDER gained 16 Exp. Points!
CHARMANDER grew to Lv. 7!

This is quite a substantial change and should be planned well before any implementation starts. It's also probably too early to be concerned with this at the moment.

Related:

12

dyc3 commented 3 years ago

What if we could just serialize the transactions to bytes? We wouldn't need to write tons of code to create those strings.

adapap commented 3 years ago

Perhaps for testing purposes that would be sufficient. Then I guess we can create the battle output as a subpackage for use with something like a CLI or the REST API.