mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-26 21:56:02 +03:00
23 lines
278 B
Go
23 lines
278 B
Go
package memento
|
|
|
|
func ExampleGame() {
|
|
game := &Game{
|
|
hp: 10,
|
|
mp: 10,
|
|
}
|
|
|
|
game.Status()
|
|
progress := game.Save()
|
|
|
|
game.Play(-2, -3)
|
|
game.Status()
|
|
|
|
game.Load(progress)
|
|
game.Status()
|
|
|
|
// Output:
|
|
// Current HP:10, MP:10
|
|
// Current HP:7, MP:8
|
|
// Current HP:10, MP:10
|
|
}
|