Skip to content

Instantly share code, notes, and snippets.

@eiwi1101
Last active July 12, 2018 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiwi1101/988bf415065fdc7ee44aad9dbd77930c to your computer and use it in GitHub Desktop.
Save eiwi1101/988bf415065fdc7ee44aad9dbd77930c to your computer and use it in GitHub Desktop.
Some noodling for an RPG backend.
class Items::Flour < Item
name "Flour"
description "Looks like crushed up wheat to you. Keep dry."
value 2.copper
stack_size 20
# Use with a Bucket of Water to create Dough. Requires
# level 1 or greater cooking.
use_with Item::BucketOfWater, create: [Item::Dough, Item::Bucket], skills: { Skill::Cooking => 1 }
end
class Items::Bucket < Item
name "Empty Bucket"
description "I wonder what this could hold?"
value 10.copper
stack_size 1
# Creates a bucket of water when used with a Water resource.
use_with Resource::Water, create: Item::BucketOfWater
end
class Items::BucketOfWater < Item
name "Bucket of Water"
description "About one water unit of water. Use wisely."
value 20.copper
stack_size 1
# Drinkable - Restores MP equivalent to the first value.
# Will restore 200 mana and remove any 'dehydration' type stat.
# Drinking requires level 0.
drinkable 200, remove_effect: :dehydration, level: 0
end
class Items::Dough < Item
name "Basic Dough"
description "Doesn't taste very good, but it'll make some fine bread if heated."
value 24.copper
stack_size 10
# Edible - Restores HP equivalent to the first value.
# Will remove 1 HP and probably give you a stomachache if you eat it.
edible -1, add_effect: Effects::Stomachache
# Use with Fire to cook. This method of use_with accepts a block which is
# passed, currently, an action instance? Like an event, I think. So, here
# we use a.create to show that this action created a thing. Player is also
# available on this action.
#
use_with Resource::Fire, skills: { Skill::Cooking => 1 } do |a|
# I don't quite like how a roll is written here. Maybe something like:
# Roll.skill? a.player, Cooking, 5
# as a shortcut, to expand out to a full roll like what I have below.
# Skill rolls are always d20 based, I think?
#
if Roll.new(20, mod: a.player.skills[Cooking].mod, dc: 5).success?
a.create Item::Bread
else
a.create Item::BurnedBread
end
end
end
class Items::Bread
name "Hard Bread"
description "It doesn't taste very good, but it'll make you feel better."
value 30.copper
stack_size 20
edible 200, remove_effect: :hunger, level: 0
end
class Items::BurnedBread
name "Burned Bread"
description "You probably shouldn't eat this."
value 0
stack_size 20
edible -1, level: 0 do |a|
# now HERE, action looks a bit like the use_with action that you had earlier.
# this time, we're going to do a bit of emoting.
a.player.emote_random [
"{is} feeling very unwell.",
"shouldn't have eaten the burned bread."
]
end
end
# Perhaps this is what a simple quest looks like?
class Quests::MakingBread < Quest
name "Making Bread"
level 1
questgiver Npc::ChefJordanDamsey
description <<-TEXT
So, you fancy yourself a cook? If you can figure out how to make me 10
lumps of bread without burning them, I'll give you my hat.
TEXT
# Now for Requirements, we can safely remove the keys and assume that
# we meant items for items, and kills for an NPC?
# This also propmpts a valid query, what's the difference between an NPC
# and some other world mob?
# DISCUSS
requires items: {
Item::Bread => 10
},
kills: {
Npc::UselessKitchenCook => 1
}
# I feel like this can be cleaned up a bit, no? Or should it be
# assumed that the first is a glob of items, followed by various other
# 'intangible' rewards? Also, an integer value is assumed to mean
# money, since money isn't an item but kinda is?
#
reward Item::ChefsHat,
20.silver,
xp: 200,
skill_xp: {
Skill::Cooking => 200
}
end
# It would also appear that the room should be in a building, which
# should be in a city, which should be in a zone. What makes a building?
# Should it be a structure?
class Rooms::TheLionsInn < Room
name "The Lion's Inn"
city Cities::BaelDen
zone Zones::TheNomadReach
exit east: Rooms::Foyer
description <<-TEXT
You find yourself standing in a rather comfortable inn. Around you,
song and dance play to your delight.
TEXT
npc Npc::UselessKitchenCook
phase do
quest_incomplete Quests::MakingBread
item Item::Bread, 10, global: true
end
phase do
quest_complete Quests::MakingBread
exit south: Rooms::Kitchen
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment