Skip to content

Instantly share code, notes, and snippets.

@eevee
Forked from amirrajan/encounters.rb
Last active March 30, 2019 03:15
Show Gist options
  • Save eevee/1d2cf2987f0065d1d4624ce0f5838eef to your computer and use it in GitHub Desktop.
Save eevee/1d2cf2987f0065d1d4624ce0f5838eef to your computer and use it in GitHub Desktop.
# this could be made to work with surprisingly little effort.
# no, i won't tell you how. please don't do it
class SnarlingBeastEvent(EncounterEvent):
language = 'english'
title = "a snarling beast"
text = "a snarling beast leaps out of the underbrush."
language = 'pig latin'
title = "anway arlingsnay eastbay"
text = "anway arlingsnay eastbay eapslay outway ofway ethay underbrushway."
enemy = 'snarling_beast'
damage = 1
health = 5
attack_delay = 1
hit = 0.8
loot = MultiLoot(
Loot(Fur, min=1, max=3, chance=1),
Loot(Meat, min=1, max=3, chance=1),
Loot(Teeth, min=1, max=3, chance=0.8),
)
// ES6 classes don't support class attributes (STILL, ugh), but you can cheat a bit
function make_encounter(data) {
let encounter_type = Object.create(EncounterEvent.prototype);
for (let [k, v] of Object.entries(data)) {
encounter_type.prototype[k] = v;
}
return encounter_type;
}
local SnarlingBeastEvent = make_encounter({
title: "a snarling beast",
text: "a snarling beast leaps out of the underbrush.",
enemy: 'snarling_beast',
damage: 1,
health: 5,
attack_delay: 1,
hit: 0.8,
// ok js syntax kinda sucks here
loot: new MultiLoot(
new Loot(Fur, 1, 3, 1.0),
new Loot(Meat, 1, 3, 1.0),
new Loot(Teeth, 1, 3, 0.8),
),
});
-- Lua doesn't have built-in classes, just a toolbox of bits you can use to make them, so this will vary
local SnarlingBeastEvent = EncounterEvent:extend{
title = "a snarling beast",
text = "a snarling beast leaps out of the underbrush.",
enemy = 'snarling_beast',
damage = 1,
health = 5,
attack_delay = 1,
hit = 0.8,
loot = MultiLoot(
Loot{item=Fur, min=1, max=3, chance=1},
Loot{item=Meat, min=1, max=3, chance=1},
Loot{item=Teeth, min=1, max=3, chance=0.8}),
}
# completely vanilla syntax
class SnarlingBeastEvent(EncounterEvent):
title = "a snarling beast"
text = "a snarling beast leaps out of the underbrush."
enemy = 'snarling_beast'
damage = 1
health = 5
attack_delay = 1
hit = 0.8
# making this a def that returns a literal is an odd choice;
# here's something more typed
loot = MultiLoot(
Loot(Fur, min=1, max=3, chance=1),
Loot(Meat, min=1, max=3, chance=1),
Loot(Teeth, min=1, max=3, chance=0.8),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment