This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DivZero { | |
public static void main(String[] args) { | |
try { | |
int result = 5 / 0; | |
} catch (ArithmeticException e) { | |
System.out.println("Caught a DIV/0!"); | |
throw e; | |
} | |
System.out.println("Alive?!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DivZero { | |
public static void main(String[] args) { | |
try { | |
int result = 5 / 0; | |
} catch (ArithmeticException e) { | |
System.out.println("Caught a DIV/0!"); | |
throw e; | |
} | |
System.out.println("Alive?!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vehicle.java | |
public interface Vehicle { | |
public int wheels(); | |
} | |
// Test.java | |
public class Test { | |
public static void main(String[] args) { | |
Vehicle car = new Vehicle() { | |
public int wheels() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
my $message = shift; | |
qx/gmessage -display :0.0 -center -geometry 800x400 -borderless -bg "#000000" -fg "#00ff00" -font 40 "$message"/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns combat) | |
(defn roll | |
"roll the dice (roll 1 6) => 1d6, (roll 2 6) => 2d6" | |
[dice max] | |
(apply + (for [x (range dice)] (inc (rand-int max))))) | |
(defn weapon-dmg | |
"calculates a damage roll for the given weapon" | |
[weapon] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns monsters | |
(:use weapons) | |
(:use abilities)) | |
(def grid-bug | |
{:level 0, | |
:exp 4, | |
:ac 9, | |
:mr 0, | |
:weapon (bite 1 1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns experience | |
(:use combat)) | |
; experience table handling progression between levels | |
(def xp-table | |
{1 0, | |
2 20, | |
3 40, | |
4 80, | |
5 160, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns weapons) | |
(def dagger | |
; 1d3 dagger | |
{:dmg [1 3], | |
:name "dagger"}) | |
(def short-sword | |
; 1d6 short sword | |
{:dmg [1 6] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns util) | |
(defn pickup | |
"generic helper to pickup an item" | |
[entity item slot] | |
(dosync (alter entity assoc slot item))) | |
(defn take-weapon | |
"set an entity to wield a weapon" | |
[entity weapon] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns id-gen) | |
(def ids "abcdefghijklmnopqrstuvwxyz") | |
(defn create-generator [] | |
"returns a generator ref" | |
(ref {:ids ids, :pos 0})) | |
(defn- inc-gen | |
"increments generator counter |