From 9dbb4b1c10aa87c1b296752467ec6d6983247aa6 Mon Sep 17 00:00:00 2001 From: Darren Bane Date: Wed, 27 Jan 2021 19:52:36 +0000 Subject: Fix after editor vomited everywhere --- loot.lsp | 132 +++++++++++++++------------------------------------------------ 1 file changed, 30 insertions(+), 102 deletions(-) diff --git a/loot.lsp b/loot.lsp index 857c7af..4dfb2c8 100644 --- a/loot.lsp +++ b/loot.lsp @@ -4,110 +4,38 @@ (defconstant +max-probability+ 1000) ;; Because this is a simple enum and not a full sum/product type, ;; I use symbols instead of CLOS. -(defconstant +loot-type+ (vector 'bloodstone 'copper 'emeraldite 'gold - 'heronite 'platinum 'shaownite 'silver - 'soranite 'umbrarite 'cobalt 'iron - 'nothing)) +(defconstant +loot-type+ #(bloodstone copper emeraldite gold + heronite platinum shadownite silver + soranite umbrarite cobalt iron + nothing)) (defclass () ((probabilities :accessor probabilities))) (defgeneric choose (self)) (defmethod choose ((self )) - (let ((random-value (random (- +max-probability+ 1)))) - (for ((loop 0 (+ loop 1))) - ((>= (elt (probabilities self) (mod loop 13)) random-value) (elt +loot-type+ (mod loop 13)))))) + (let ((random-value (random (- +max-probability+ 1)))) + (for ((loop 0 (+ loop 1))) + ((>= (elt (probabilities self) (mod loop 13)) random-value) (elt +loot-type+ (mod loop 13)))))) (defmethod initialize-object :after ((self ) initargs) - (setf (probabilities self) (vector 10 77 105 125 142 159 172 200 201 202 216 282 +max-probability+ (case l - ((bloodstone) "Bloodstone") - ((copper) "Copper") - ((emeraldite) "Emeraldite") - ((gold) "Gold") - ((heronite) "Heronite") - ((platinum) "Platinum") - ((shadownite) "Shadownite") - ((silver) "Silver") - ((soranite) "Soranite") - ((umbrarite) "Umbrarite") - ((cobalt) "Cobalt") - ((iron) "Iron") - (t ""))) + (setf (probabilities self) (vector 10 77 105 125 142 159 172 200 201 202 216 282 +max-probability+))) +(defun as-string (l) + ;; Could use assoc here, but this is closer to the original. + ;; Also saves translating nil to "". + (case l + ((bloodstone) "Bloodstone") + ((copper) "Copper") + ((emeraldite) "Emeraldite") + ((gold) "Gold") + ((heronite) "Heronite") + ((platinum) "Platinum") + ((shadownite) "Shadownite") + ((silver) "Silver") + ((soranite) "Soranite") + ((umbrarite) "Umbrarite") + ((cobalt) "Cobalt") + ((iron) "Iron") + (t ""))) (defun main () - (let ((loot (create (class ))) (for ((n 0 (+ n 1))) - - ((> n 99)) - (format (standard-output) "~A~%" (as-string (choose loot)))))) - - -. /usr/local/plan9/bin/9.rc -if (test -d /usr/local/bin) { - path = (/usr/local/bin $path) -} -if (test -d /usr/local/opt/emacs-plus/bin) { - path = ($path /usr/local/opt/emacs-plus/bin) -} -if (test -d $home/bin) { - path = ($path $home/bin) -} -if (test -d $home/opt/GNAT/2020/bin) { - path = ($home/opt/GNAT/2020/bin $path) -} - -OPENLISP = $home/openlisp-11.0.0 -if (test -d $OPENLISP) { - path = ($path $OPENLISP) -} - -# These break some commands like man. -# Use the new names instead. -#fn grep { rg $* } -#fn ls { exa $* } -#fn find { fd $* } -#fn cat { bat $* } -#fn more { bat $* } -#fn xterm { alacritty $* } - -#prompt = ('$ ' '$ ') -REFER = $home/lsp/doc/refs - -if (test -d $home/.cargo/bin) { - path = ($home/.cargo/bin $path) -} - -if (test -d /usr/local/opt/tcl-tk/bin) { - path = (/usr/local/opt/tcl-tk/bin $path) -} - -if (test -d $home/obnc/usr/local/bin) { - path = ($path $home/obnc/usr/local/bin) -} - -if (test -d $home/.emacs.d/bin) { - path = ($path $home/.emacs.d/bin) -} -fn doom { u doom $* } -if (test -d /Applications/Emacs.app/Contents/MacOS/bin) { - path = ($path /Applications/Emacs.app/Contents/MacOS/bin) -} -if (test -f /Applications/Emacs.app/Contents/MacOS/Emacs) { - EMACS = /Applications/Emacs.app/Contents/MacOS/Emacs - fn emacs { u $EMACS -nw $* } -} -if (test -f /Applications/Emacs.app/Contents/MacOS/bin/emacsclient) { - fn emacsclient { u /Applications/Emacs.app/Contents/MacOS/bin/emacsclient $* } -} - -LANG = en_IE.UTF-8 -TZ = Europe/Dublin -LESS_IS_MORE = t -MORE = '-SEXIER' -POSIXLY_CORRECT = t -REFER = $home/lsp/doc/refs - -if (test -d $home/context/tex/texmf-osx-64/bin) { - path = ($path $home/context/tex/texmf-osx-64/bin) -} - -if (test -d $home/Library/Python/3.8/bin) { - path = ($path $home/Library/Python/3.8/bin) -} - -TCLLIBPATH = $home/lib/tklib0.7 - + (let ((loot (create (class )))) + (for ((n 0 (+ n 1))) + ((> n 99)) + (format (standard-output) "~A~%" (as-string (choose loot)))))) +(main) -- cgit 1.4.1-2-gfad0 r: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
Copyright (c) 2020, Andinus <andinus@inventati.org>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.