Skip to content

Commit

Permalink
Fix shade generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruin0x11 committed Mar 2, 2021
1 parent a416032 commit 37d9948
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/mod/elona/api/Magic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Enum = require("api.Enum")
local SkillCheck = require("mod.elona.api.SkillCheck")
local Log = require("api.Log")
local Hunger = require("mod.elona.api.Hunger")
local Const = require("api.Const")

local Magic = {}

Expand Down
2 changes: 1 addition & 1 deletion src/mod/elona/data/magic/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ local function proc_curse(chara)
if Rand.one_in(10) and chara.gold > 0 then
local lose_amount = math.min(Rand.rnd(chara.gold) / 100 + Rand.rnd(10) + 1, chara.gold)
chara.gold = chara.gold - lose_amount
Gui.mes_c_visible("misc.curse.gold_stolen", chara, "Purple")
Gui.mes_c_visible("misc.curse.gold_stolen", chara.x, chara.y, "Purple", chara)
return
end
-- <<<<<<<< elona122/shade2/item.hsp:446 return ..
Expand Down
16 changes: 11 additions & 5 deletions src/mod/elona/events/charagen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local I18N = require("api.I18N")
local Skill = require("mod.elona_sys.api.Skill")
local CharaMake = require("api.CharaMake")
local Const = require("api.Const")
local Map = require("api.Map")

local function fix_name_gender_age(chara)
if chara.proto.has_own_name then
Expand Down Expand Up @@ -186,7 +187,6 @@ end
Event.register("base.on_initialize_player", "Init player defaults", init_player_defaults)

local function init_chara_image(chara)
print(chara.image, chara._id)
if chara.image == "base.default" then
if chara.male_image and chara.gender == "male" then
chara.image = chara.male_image
Expand Down Expand Up @@ -220,8 +220,10 @@ Event.register(
return result
end

params.level = params.level * 2
if params.quality > Enum.Quality.Good then
if params.level then
params.level = params.level * 2
end
if params.quality and params.quality > Enum.Quality.Good then
params.quality = Enum.Quality.Good
end
local Charagen = require("mod.tools.api.Charagen")
Expand All @@ -231,11 +233,15 @@ Event.register(
local chara = MapObject.generate_from("base.chara", params.id)

chara.is_shade = true
chara.title = "shade"
chara.name = I18N.get("chara.job.shade")
chara.image = "elona.chara_shade"
-- <<<<<<<< shade2/chara.hsp:485 if cmShade:cnName(rc)=lang("シェイド","shade"): cPic( ...

chara = MapObject.build(chara, params.gen_params)
if params.where then
Map.try_place_chara(chara, params.x, params.y, params.where)
end

MapObject.finalize(chara, params.gen_params)

return chara
end)
54 changes: 0 additions & 54 deletions src/test/unit/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,57 +84,3 @@ function test_event_emitter_callbacks_restored()
Assert.is_truthy(item:has_event_handler("elona_sys.on_item_use"))
end
end

function test_object_set_item_prototype__event_callbacks_added()
do
local map = InstancedMap:new(10, 10)
map:clear("elona.cobble")

local player = Chara.create("base.player", 5, 5, {}, map)
Chara.set_player(player)
test_util.register_map(map)

local item = Item.create("base.nonuseable", nil, nil, {}, player)
Assert.is_falsy(item:has_event_handler("elona_sys.on_item_use"))

item:set_object_prototype("base.useable")
Assert.is_truthy(item:has_event_handler("elona_sys.on_item_use"))
end

test_util.save_cycle()

do
local player = Chara.player()
local map = player:current_map()
local item = Item.find("base.useable", "all", map)

Assert.is_truthy(item:has_event_handler("elona_sys.on_item_use"))
end
end

function test_object_set_item_prototype__event_callbacks_removed()
do
local map = InstancedMap:new(10, 10)
map:clear("elona.cobble")

local player = Chara.create("base.player", 5, 5, {}, map)
Chara.set_player(player)
test_util.register_map(map)

local item = Item.create("base.useable", nil, nil, {}, player)
Assert.is_truthy(item:has_event_handler("elona_sys.on_item_use"))

item:set_object_prototype("base.nonuseable")
Assert.is_falsy(item:has_event_handler("elona_sys.on_item_use"))
end

test_util.save_cycle()

do
local player = Chara.player()
local map = player:current_map()
local item = Item.find("base.nonuseable", "all", map)

Assert.is_falsy(item:has_event_handler("elona_sys.on_item_use"))
end
end

0 comments on commit 37d9948

Please sign in to comment.