Help with Objects/Functions with arguments
Posted: Wed Dec 27, 2017 8:13 pm
Hello! I am programming a Pokemon Stadium/Battler in CLisp, and I am having trouble making a damage function that takes values from a move and a pokemon, and doing math with it. In the example below, I am using the move "Blizzard" and the pokemon "Cloyster".
Here are the classes as well:
The Damage Function:
If you also find sloppy or redundant code, please help me out and make it shorter.
Thanks much!
Code: Select all
;;----------BLIZZARD--------;;
(defparameter *Blizzard* (make-instance 'Moves))
(setf (slot-value *Blizzard* 'NAME) "Blizzard")
(setf (slot-value *Blizzard* 'BASEDMG) 120)
(setf (slot-value *Blizzard* 'PP) 5)
(setf (slot-value *Blizzard* 'ACCURACY) 90)
(setf (slot-value *Blizzard* 'STATUS) nil)
(setf (slot-value *Blizzard* 'TYPING) "Ice")
(setf (slot-value *Blizzard* 'CATEGORY) "Special")
;;Cloyster
(defparameter *Cloyster* (make-instance 'Pokemon))
(setf (slot-value *Cloyster* 'HP) 156)
(setf (slot-value *Cloyster* 'ATK) 146)
(setf (slot-value *Cloyster* 'DEF) 231)
(setf (slot-value *Cloyster* 'SPECIAL) 136)
(setf (slot-value *Cloyster* 'SPEED) 121)
(setf (slot-value *Cloyster* 'TYPEONE) "Ice")
(setf (slot-value *Cloyster* 'TYPETWO) "Water")
(setf (slot-value *Cloyster* 'LEVEL) 50)
Code: Select all
(defclass Pokemon ()
(HP
ATK
DEF
SPECIAL
SPEED
TYPEONE
TYPETWO
LEVEL
ATTACKONE
ATTACKTWO
ATTACKTHREE
ATTACKFOUR))
(defclass Moves ()
(NAME
BASEDMG
PP
ACCURACY
STATUS
TYPING
CATEGORY))
Code: Select all
(defun Damage (Moves Pokemon)
(+ (/ (* (* (+ (/ 100 5) 2) BASEDMG) (/ ATK DEF)) 50) 2))
Thanks much!
