Skip to content

Commit

Permalink
Merge pull request #4 from timothymtorres/condense-skills-and-classes
Browse files Browse the repository at this point in the history
Remove medical and sentient classes
  • Loading branch information
timothymtorres committed Nov 14, 2016
2 parents 5be401b + 275f9dc commit 9676ba6
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 238 deletions.
8 changes: 5 additions & 3 deletions code/item/list/gadget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gadget.radio.durability = 100
gadget.GPS = {} -- GPS for humans should have a small chance to grant a free AP for movement
gadget.GPS.full_name = 'global position system'
gadget.GPS.weight = 2
gadget.GPS.durability = 300
gadget.GPS.durability = 50

--[[
gadget.cellphone = {}
Expand All @@ -33,11 +33,13 @@ gadget.loudspeaker = {}
gadget.loudspeaker.full_name = 'loudspeaker'
gadget.loudspeaker.weight = 1
--used for searching? give search bonus?!
--]]

gadget.flashlight = {}
gadget.flashlight.full_name = 'flashlight'
gadget.flashlight.weight = 4
--]]
gadget.flashlight.durability = 100


for item in pairs(gadget) do gadget[item].class_category = 'research' end

Expand Down
12 changes: 2 additions & 10 deletions code/item/list/medical.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@ local medical = {}
medical.FAK = {}
medical.FAK.full_name = 'first aid kit'
medical.FAK.weight = 8
medical.FAK.class_category = 'medical'

medical.bandage = {}
medical.bandage.full_name = 'bandage'
medical.bandage.weight = 3
medical.bandage.class_category = 'medical'

medical.antidote = {}
medical.antidote.full_name = 'vial of antidote'
medical.antidote.weight = 1
medical.antidote.class_category = 'medical'

medical.syringe = {}
medical.syringe.full_name = 'revival syringe'
medical.syringe.full_name = 'syringe'
medical.syringe.weight = 5
medical.syringe.designated_weapon = true
medical.syringe.class_category = 'research'

for item in pairs(medical) do
medical[item].one_use = true
medical[item].class_category = 'research'
end

return medical
65 changes: 33 additions & 32 deletions code/item/use/activate.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local dice = require('code.libs.dice')
local flags = require('code.player.skills.flags')
local medical = require('code.item.medical.class')

local activate = {}
Expand All @@ -12,38 +11,38 @@ function activate.FAK(player, condition, target)
local FAK_dice = dice:new(medical.FAK:getDice())
local tile = player:getTile()

if player.skills:check(flags.recovery) and tile:isBuilding() and tile:isPowered() and player:isStaged('inside') then
if player.skills:check('healing') and tile:isBuilding() and tile:isPowered() and player:isStaged('inside') then
FAK_dice = FAK_dice*1
--print('powered confirmed')
--print(tile:getClassName(), tile:getName(), tile:getTileType() )
if player.skills:check(flags.major_healing) and tile:isClass('hospital') then
if player.skills:check('major_healing') and tile:isClass('hospital') then
FAK_dice = FAK_dice*1
--print('hosptial confirmed')
end
end

if player.skills:check(flags.major_healing_adv) then
if player.skills:check('major_healing') then
FAK_dice = FAK_dice^1
FAK_dice = FAK_dice..'^^'
end
end

local hp_gained = FAK_dice:roll()
target:updateHP(hp_gained)
-- target:event trigger
print('You heal with '..FAK:getName()..' for '..hp_gained..' hp.')
print('You heal with the first aid kit for '..hp_gained..' hp.')
end

function activate.bandage(player, condition, target)
local bandage_dice = dice:new(medical.bandage:getDice())
local tile = player:getTile()

if tile:isBuilding() and tile:isPowered() and player:isStaged('inside') then bandage_dice = bandage_dice+1 end

if player.skills:check(flags.recovery) then
if player.skills:check('healing') then
bandage_dice = bandage_dice+1
if player.skills:check(flags.minor_healing) then
bandage_dice = bandage_dice+1
if player.skills:check(flags.major_healing_adv) then
bandage_dice = bandage_dice^1
bandage_dice = bandage_dice+1
end
if player.skills:check('minor_healing') then
bandage_dice = bandage_dice+1
bandage_dice = bandage_dice^1
end
end

Expand All @@ -53,29 +52,25 @@ function activate.bandage(player, condition, target)
print('You heal with '..bandage:getName()..' for '..hp_gained..' hp.')
end

function activate.antidote(player, condition, target)
local antidote = medical.antidote
local cure_chance = antidote:getAccuracy()
-- modify chance based on skills?

local cure_success = cure_chance >= math.random()
-- target:updateStatusEffects?
-- target:event trigger
if cure_success then
print('You cure with the '..antidote:getName()..'.')
else
print('You fail to cure with the '..antidote:getName()..'.')
end
end
local syringe_hp_ranges = {3, 6, 9, 12}

function activate.syringe(player, condition, target)
local syringe = medical.syringe
local inject_chance = syringe:getAccuracy()
-- modify chance based on skills?
if player.skills:check('syringe') then
inject_chance = inject_chance + 0.05
if player.skills:check("syringe_adv") then
inject_chance = inject_chance + 0.05
end
end

local inject_success = inject_chance >= math.random()
target:killed('syringe')
local target_weak_enough = syringe_hp_ranges[condition] >= target:getStat('hp')

if inject_success and target_weak_enough then target:killed() end
-- target:event trigger

return {inject_success, target_weak_enough}
end

--[[
Expand Down Expand Up @@ -104,8 +99,15 @@ function activate.sampler(player, condition, target)

end

function activate.GPS(player, condition)
local GPS_basic_chance, GPS_advanced_chance = 0.15, 0.20

function activate.GPS(player, condition)
local GPS_chance = (player.skils:check('gadgets') and GPS_advanced_chance) or GPS_basic_chance
local free_movement_success = GPS_chance >= math.random()
if free_movement_success then -- the GPS has a chance to avoid wasting ap on movement
player:updateStat('ap', 1) -- this is pretty much a hack (if a player's ap is 50 then they will NOT receive the ap)
end
return {free_movement_success}
end

function activate.loudspeaker(player, condition, message)
Expand Down Expand Up @@ -158,8 +160,7 @@ local book_xp_dice = {'1d3', '1d5', '1d7', '1d10'}
function activate.book(player, condition)
local xp_dice_str = book_xp_dice[condition-1]
local book_dice = dice:new(xp_dice_str)
if player.skills:check(flags.bookworm) then book_dice = book_dice^1 end
if player:isStaged('inside') and player:getSpotCondition() == 'powered' then book_dice = book_dice/2 end
if player:isStaged('inside') and player:getSpotCondition() == 'powered' then book_dice = book_dice^1 end
local gained_xp = book_dice:roll()
player:updateXP(gained_xp)
end
Expand Down
12 changes: 6 additions & 6 deletions code/player/action/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ local action_list = {
zombie = {
default = {
move = {name='move', cost=2, modifier={sprint = -1},},
enter = {name='enter', cost= 1},
exit = {name='exit', cost= 1},
enter = {name='enter', cost=1},
exit = {name='exit', cost=1},
},
basic = {
respawn = {cost=10, modifier={resurrection = -5},},
attack = {cost=1},
speak = {cost=1},
feed = {cost=1},
respawn = {cost= 10, modifier={resurrection = -5},},
attack = {cost= 1},
speak = {cost= 1},
feed = {cost= 1},
},
skill = {
-- generic skills
Expand Down
45 changes: 35 additions & 10 deletions code/player/action/outcome.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
--[[
local lookupItem = require('code.item.search')
local lookupWeapon= require('code.item.weapon.search')
--]]
local map = require('code.location.map.class')
local combat = require('code.player.combat')
local entangle = require('code.player.condition.entangle')
Expand All @@ -10,6 +6,8 @@ local equipmentActivate = require('code.location.building.equipment.operation.ac
local skillActivate = require('code.player.skills.activate')
local enzyme_list = require('code.player.enzyme_list')
local dice = require('code.libs.dice')
local item = require('code.item.class')


Outcome = {}

Expand Down Expand Up @@ -39,6 +37,7 @@ function Outcome.move(player, dir)
local y, x = player:getPos()
local map = player:getMap()
local dir_y, dir_x = getNewPos(y, x, dir)
local GPS_usage

if player:isStaged('inside') then
map[y][x]:remove(player, 'inside')
Expand All @@ -47,13 +46,20 @@ function Outcome.move(player, dir)
else
map[dir_y][dir_x]:insert(player, 'outside')
end
else
else -- player is outside
if player:isMobType('human') then
local inventory_has_GPS, inv_ID = player.inventory:search('GPS')
if inventory_has_GPS then
GPS_usage = Outcome.item('GPS', player, inv_ID)
end
end

map[y][x]:remove(player)
map[dir_y][dir_x]:insert(player)
end

player:updatePos(dir_y, dir_x)
return {dir}
return {dir, GPS_usage}
end

local ARMOR_DAMAGE_MOD = 2.5
Expand All @@ -63,8 +69,8 @@ function Outcome.attack(player, target, weapon, inv_ID)
local attack, damage, critical = combat(player, target, weapon)

if attack then
if target_class == 'player' then -- what about barricades? buildings? equipment?
if target.armor:isPresent() then -- what if weapon is harmless?
if target_class == 'player' then
if target.armor:isPresent() and not weapon:isHarmless() then
local damage_type = weapon:getDamageType()
local resistance = target.armor:getProtection(damage_type)
damage = damage - resistance
Expand All @@ -88,6 +94,9 @@ function Outcome.attack(player, target, weapon, inv_ID)
if zombie.skills:check('track') then
zombie.condition.tracking:addScent(human)
end
--elseif target_class == 'building' then
--elseif target_class == 'barricade' then
--elseif target_class == equipment?
end

local hp_loss = -1*damage
Expand Down Expand Up @@ -208,8 +217,24 @@ function Outcome.item(item, player, inv_ID, target)
local item_INST = player.inventory:lookup(inv_ID)
local item_condition = item_INST:getCondition()
local result = itemActivate[item](player, item_condition, target)
if item_INST:isSingleUse() then player.inventory:remove(inv_ID) -- no need to do a durability check
elseif item_INST:failDurabilityCheck(player) then item_INST:updateCondition(-1, player, inv_ID) end

if item_INST:isSingleUse() then -- no need for durability check
if item_INST:getClassName() == 'syringe' then
local inject_success, target_weak_enough = result[1], result[2]
if inject_success then
if target_weak_enough then -- the syringe will be discarded without creating a vaccine if the target is too strong
local vaccine = item.vaccine:new('unpowered') -- should probably make unpowered/powered condition dependent on syringe skills
player.inventory:insert(vaccine)
end
player.inventory:remove(inv_ID)
--else the syringe is not removed from inventory since it didn't hit
end
else -- all other single use items get discarded
player.inventory:remove(inv_ID)
end
elseif item_INST:failDurabilityCheck(player) then
item_INST:updateCondition(-1, player, inv_ID)
end
return result
end

Expand Down
10 changes: 4 additions & 6 deletions code/player/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ local condition = require('code.player.condition.class')
local carcass = require('code.player.carcass')
local organic_armor = require('code.player.armor.organic_class')
local item_armor = require('code.player.armor.item_class')
local flags = require('code.player.skills.flags')
local weapon = require('code.item.weapon.class')
--[[
local lookupWeapon = require('code.item.weapon.search') -- refactored? (delete)
local lookupItem = require('code.item.search') -- refactored? (delete)
--]]

local player = class('player')

Expand Down Expand Up @@ -54,7 +49,10 @@ function player:killed(cause_of_death)
#1 - human killed (turns into zombie) [reset skills, xp, sp]
#2 - zombie killed (decay) [delete]
#3 - zombie killed (regular death) [nothing]
--]]
--]]

self.hp, self.health_state = 0, {basic=4, advanced=8} -- reset our hp stats to zero

if self:isMobType('human') then
self.hp, self.health_state = 0, {basic=4, advanced=8}
self:updateMobType('zombie')
Expand Down
12 changes: 10 additions & 2 deletions code/player/inventory.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local item = require('code.item.class')
local class = require('code.libs.middleclass')

local inventory = class('code.player.inventory')
Expand All @@ -16,7 +15,7 @@ function inventory:initialize()
self.radio_receivers = {}
end

function inventory:insert(obj_INST) self[#self+1] = obj_INST end
function inventory:insert(item_INST) self[#self+1] = item_INST end

function inventory:remove(inv_ID) table.remove(self, inv_ID) end

Expand All @@ -29,6 +28,15 @@ function inventory:lookup(inv_ID) -- get itemClass_INST
return self[inv_ID]
end

function inventory:search(item_name)
for inv_ID, item_INST in ipairs(self) do
if item_INST:getClassName() == item_name then
return true, inv_ID
end
end
return false
end

function inventory:catalog()
local contents = {}
for inv_ID=1, #self do contents[#contents + 1] = self[inv_ID] end
Expand Down
8 changes: 6 additions & 2 deletions code/player/log/getMessage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ end
--]]--DIR/COMPASS LAYOUT
local compass = {'North', 'NorthEast', 'East', 'SouthEast', 'South', 'SouthWest', 'West', 'NorthWest'}

function description.move(player, dir)
msg[1] = 'You travel '..compass[dir]..'.'
function description.move(player, dir, GPS_usage)
if GPS_usage then
msg[1] = 'You travel '..compass[dir]..' using a GPS.'
else
msg[1] = 'You travel '..compass[dir]..'.'
end
end

function description.search(player, item)
Expand Down
Loading

0 comments on commit 9676ba6

Please sign in to comment.