;;;; Ru*** roLeplay Playground virtual tabletop ;;;; Copyright (C) 2022 Zull ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU General Public License ;;;; along with this program. If not, see . (in-package :rulp.layers) (defgeneric create-entity (m)) (defclass model () ((name :initarg :name :accessor name :documentation "name of the model, it will be transfered to the entity when generated" :initform "noname" :type string) (properties :accessor properties :initarg :properties :documentation "an a-list of the properties of the entity" :initform nil) (size :accessor size :initarg :size :documentation "the size of a model, it will be calculated with the grid for the dimension in board" :type integer :initform 1) (interactions :initform '(pokep) :accessor interactions :documentation "interactions are function the entity can use, these are associated with some property" :initarg :interactions) )) (defmethod create-entity ((m model)) "create an entity from the standard model" (let* ((return-entity m)) (make-instance 'entity :name (name m) :propreties (propreties m) :size (size m) :interactions (interactions m)))) ;; the dice set, this has many uses, it is called by ;; interactions when actions are done, it is called ;; on entity creation for life randomization (the ;; create-entity function eval the supplied data) (defun dice (dice-type number-dices &key (plus 0)) "throw the dice-type n times based on number-dices" (+ 1 plus (loop :for i :from 1 :to number-dices :sum (random dice-type)))) (defun d4 (number-dices &key (plus 0)) "shortcut for the dice function with d4" (dice 4 number-dices :plus plus)) (defun d6 (number-dices &key (plus 0)) "shortcut for the dice function with d6" (dice 6 number-dices :plus plus)) (defun d8 (number-dices &key (plus 0)) "shortcut for the dice function with d8" (dice 8 number-dices :plus plus)) (defun d10 (number-dices &key (plus 0)) "shortcut for the dice function with d10" (dice 10 number-dices :plus plus)) (defun d12 (number-dices &key (plus 0)) "shortcut for the dice function with d12" (dice 12 number-dices :plus plus)) (defun d20 (number-dices &key (plus 0)) "shortcut for the dice function with d20" (dice 20 number-dices :plus plus)) (defun d100 (number-dices &key (plus 0)) "shortcut for the dice function with d100" (dice 100 number-dices :plus plus)) (defun dice-from-list (list-dices &key (plus 0)) "throw and sums all the dices from a list, the plus modificator is added once at the end of the sum (Xd4+Yd6+Zd8+...+p)" (+ 1 plus (loop :for i :in list-dices :sum (random i))))