86 lines
3.5 KiB
Common Lisp
86 lines
3.5 KiB
Common Lisp
;;; okay so the state of the game is going to be a combination of
|
|
;;; hp
|
|
;;; turn number
|
|
;;; five pet slots (just list of pets, really)
|
|
;;; shop pet slots (including frozen and not)
|
|
;;; shop food slots (including frozen and not)
|
|
;;; gold
|
|
|
|
|
|
(defclass player-state ()
|
|
((name :reader :name :initarg :name)
|
|
(hp :accessor :hp :initform 5)
|
|
(pets :accessor :pets :initform (make-array '5))
|
|
(pet-store :accessor :pet-store)
|
|
(gold :accessor :gold :initform 10)
|
|
(grocery :accessor :grocery)
|
|
(turn :accessor :turn :initform 1)
|
|
(wins :accessor :wins :initform 0)))
|
|
|
|
(defparameter pet-list '((ant pig fish grashopper mosquito beaver otter duck horse)
|
|
(rat shrimp hedgehog flamingo spider swan peacock dodo elephant crab)
|
|
(dolphin rabbit dog snail blowfish sheep badger kangaroo camel ox giraffe)
|
|
(skunk turtle squirrel deer worm bison rooster whale penguin hippo parrot)
|
|
(scorpion rhino seal cow monkey shark turkey alligator)
|
|
(dragon leopard mammoth gorilla boar tiger snake fly blackcat)))
|
|
|
|
;; not listed here is coconut and milk which exist but aren't actually allowed to be bought
|
|
(defparameter food-list '((apple honey)
|
|
(cupcake meat pill)
|
|
(garlic salad)
|
|
(can pear)
|
|
(chili chocolate sushi)
|
|
(melon mushroom pizza steak))
|
|
|
|
(defun turn->tier (n)
|
|
(+ 1 (floor n 2)))
|
|
|
|
|
|
|
|
;; a pet is a combination of
|
|
;; name
|
|
;; hp
|
|
;; attack
|
|
;; active food
|
|
;; on faint function
|
|
;; on bought function
|
|
;; on sell function
|
|
;; end turn function
|
|
;; start combat function
|
|
;; end combat function
|
|
|
|
;; I might not do this as clos inheritance and instead just have a single object that encompasses all of this
|
|
|
|
(defclass pet ()
|
|
((name :reader :name :initarg :name)
|
|
(tier :reader :tier :initarg :tier :initform (error "tier must be set"))
|
|
(starting-hp :accessor :starting-hp :initarg :starting-hp)
|
|
(starting-attack :accesor :starting-attack :initarg :starting-attack)
|
|
(hp :accessor :hp)
|
|
(attack :accessor :attack)
|
|
(food :accessor :food)
|
|
(level :accessor :level :initform 1)
|
|
(team :reader :team :initarg team)
|
|
(handler :reader :handler :initarg handler)))
|
|
|
|
;; I want to write this in a mostly functional way, where the whole thing is an explicit function from player-state to player-state
|
|
;; part of the idea here is to emphasize a text based interchange format so people can even have different autopets clients as
|
|
;; long as there's some kind of standard for the semantics
|
|
|
|
(defun combat (pets1 pets2)
|
|
(run-combat-effects pets1 pets2))
|
|
|
|
;;;; okay so actually what I need to do is have things like taking damage, fainting, &c. things like that essentially trigger potential
|
|
;;;; events on all the individual pets in combat/in the party
|
|
;;;; in other words we need to treat it as almost like a broadcast where we test for what each pet will do with the information of what
|
|
;;;; happened
|
|
;;;; so do we want a bunch of different handler functions like I wrote above or should we, instead, just have a message type that
|
|
;;;; includes information about what happened and who it involved
|
|
|
|
;;;;let's prototype out what messages should look like
|
|
;;;; '(damage player1 3 4) the third pet on player1's team takes 4 damage
|
|
;;;; '(faint player2 2) the second pet on player2's team has fainted
|
|
;;;; '(ate apple 3) the third pet on the player's team at an apple
|
|
;;;; '(gain player1 3 4 2) the third pet on player one's team gains 4 health and 2 attack
|
|
|