Skip to content

Commit

Permalink
Merge branch 'main' into fix/missing-achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored May 11, 2024
2 parents a41d156 + 529c7a4 commit 764bc6a
Show file tree
Hide file tree
Showing 25 changed files with 865 additions and 87 deletions.
3 changes: 1 addition & 2 deletions data/scripts/talkactions/god/add_skill.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ function addSkill.onSay(player, words, param)
return true
end

-- Trim left
split[2] = split[2]:gsub("^%s*(.-)$", "%1")
split[2] = split[2]:trimSpace()

local count = 1
if split[3] then
Expand Down
8 changes: 4 additions & 4 deletions data/scripts/talkactions/god/charms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function addCharm.onSay(player, words, param)
player:sendCancelMessage("A player with that name is not online.")
return true
end
--trim left
split[2] = split[2]:gsub("^%s*(.-)$", "%1")

split[2] = split[2]:trimSpace()

player:sendCancelMessage("Added " .. split[2] .. " charm points to character '" .. target:getName() .. "'.")
target:sendCancelMessage("Received " .. split[2] .. " charm points!")
Expand Down Expand Up @@ -133,8 +133,8 @@ function setBestiary.onSay(player, words, param)
return true
end

split[2] = split[2]:gsub("^%s*(.-)$", "%1") --Trim left
split[3] = split[3]:gsub("^%s*(.-)$", "%1") --Trim left
split[2] = split[2]:trimSpace()
split[3] = split[3]:trimSpace()

local monsterName = split[2]
local mType = MonsterType(monsterName)
Expand Down
6 changes: 3 additions & 3 deletions data/scripts/talkactions/god/create_monster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ function createMonster.onSay(player, words, param)
local monsterName = split[1]
local monsterCount = 0
if split[2] then
split[2] = split[2]:gsub("^%s*(.-)$", "%1") --Trim left
split[2] = split[2]:trimSpace()
monsterCount = tonumber(split[2])
end

local monsterForge = nil
if split[3] then
split[3] = split[3]:gsub("^%s*(.-)$", "%1") --Trim left
split[3] = split[3]:trimSpace()
monsterForge = split[3]
end

if monsterCount > 1 then
local spawnRadius = 5
if split[4] then
split[4] = split[4]:gsub("^%s*(.-)$", "%1") --Trim left
split[4] = split[4]:trimSpace()
spawnRadius = split[4]
print(spawnRadius)
end
Expand Down
8 changes: 5 additions & 3 deletions data/scripts/talkactions/god/manage_badge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ function addBadge.onSay(player, words, param)
return true
end

-- Trim left
split[2] = split[2]:gsub("^%s*(.-)$", "%1")
split[2] = split[2]:trimSpace()
local id = tonumber(split[2])
target:addBadge(id)
if target:addBadge(id) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You added a badge with ID "%i" to player "%s".', id, target:getName()))
target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s added a badge to you.", player:getName()))
end
return true
end

Expand Down
3 changes: 1 addition & 2 deletions data/scripts/talkactions/god/manage_storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ function Player.getStorageValueTalkaction(self, param)
return true
end

-- Trim left
split[2] = split[2]:gsub("^%s*(.-)$", "%1")
split[2] = split[2]:trimSpace()

-- Try to convert the second parameter to a number. If it's not a number, treat it as a storage name
local storageKey = tonumber(split[2])
Expand Down
70 changes: 70 additions & 0 deletions data/scripts/talkactions/god/manage_title.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local addTitle = TalkAction("/addtitle")

function addTitle.onSay(player, words, param)
-- create log
logCommand(player, words, param)

if param == "" then
player:sendCancelMessage("Command param required.")
return true
end

local split = param:split(",")
if not split[2] then
player:sendCancelMessage("Insufficient parameters. Usage: /addtitle playerName, badgeID")
return true
end

local target = Player(split[1])
if not target then
player:sendCancelMessage("A player with that name is not online.")
return true
end

split[2] = split[2]:trimSpace()
local id = tonumber(split[2])
if target:addTitle(id) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You added a title with ID "%i" to player "%s".', id, target:getName()))
target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s added a title to you.", player:getName()))
end

return true
end

addTitle:separator(" ")
addTitle:groupType("god")
addTitle:register()

-----------------------------------------
local setTitle = TalkAction("/settitle")

function setTitle.onSay(player, words, param)
-- create log
logCommand(player, words, param)

if param == "" then
player:sendCancelMessage("Command param required.")
return true
end

local split = param:split(",")
if not split[2] then
player:sendCancelMessage("Insufficient parameters. Usage: /settitle playerName, badgeID")
return true
end

local target = Player(split[1])
if not target then
player:sendCancelMessage("A player with that name is not online.")
return true
end

split[2] = split[2]:trimSpace()
local id = tonumber(split[2])
target:setCurrentTitle(id)
return true
end

setTitle:separator(" ")
setTitle:groupType("god")
setTitle:register()
File renamed without changes.
1 change: 1 addition & 0 deletions src/creatures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target_sources(${PROJECT_NAME}_lib PRIVATE
players/player.cpp
players/achievement/player_achievement.cpp
players/cyclopedia/player_badge.cpp
players/cyclopedia/player_title.cpp
players/wheel/player_wheel.cpp
players/wheel/wheel_gems.cpp
players/vocations/vocation.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/players/cyclopedia/player_badge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "game/game_definitions.hpp"
#include "enums/player_cyclopedia.hpp"

class Player;
class KV;
Expand Down
Loading

0 comments on commit 764bc6a

Please sign in to comment.