Quest taking and rejecting
This commit is contained in:
parent
8a40de576e
commit
c6d8ae8be0
12 changed files with 87 additions and 14 deletions
|
|
@ -10,6 +10,10 @@ const BUY_ITEM = "BASE_BUY_ITEM"
|
|||
const SELL_ITEM = "BASE_SELL_ITEM"
|
||||
## This message will trigger quest node to make answer format
|
||||
const TAKE_QUEST = "BASE_TAKE_QUEST"
|
||||
## This message will trigger quest node to assign quest to player
|
||||
const ACCEPT_QUEST = "BASE_QUEST_ACCEPT"
|
||||
## This message will trigger quest node to take quest from player
|
||||
const CANCEL_QUEST = "BASE_QUEST_CANCEL"
|
||||
|
||||
@onready var dialogue = $DialogueView
|
||||
@onready var buy_sell = $"../../BuySell"
|
||||
|
|
@ -45,6 +49,13 @@ func send_message(msg: Message):
|
|||
format["item_name"] = item_name
|
||||
TAKE_QUEST:
|
||||
format["answer"] = quest.answer
|
||||
if quest.answer == tr(quest.NO_QUEST):
|
||||
get_tree().create_timer(0.05).timeout.connect(actions_menu.transit_menu.bind(0))
|
||||
ACCEPT_QUEST:
|
||||
actions_menu.player_ship.quest = quest.assign_to_player()
|
||||
CANCEL_QUEST:
|
||||
actions_menu.player_ship.quest = null
|
||||
|
||||
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
|
||||
var old_len = len(dialogue.get_parsed_text())
|
||||
dialogue.append_text(new_msg)
|
||||
|
|
|
|||
|
|
@ -2,14 +2,22 @@ extends Node
|
|||
|
||||
var base: Base
|
||||
|
||||
var quest: Quest
|
||||
## Quest this node holds
|
||||
var quest: Quest:
|
||||
set(value):
|
||||
has_quest = value != null
|
||||
quest = value
|
||||
|
||||
## Const of answer when quest is null
|
||||
const NO_QUEST = "BASE_TAKE_QUEST_FAILED"
|
||||
## Const of answer when quest is not null
|
||||
const HAS_QUEST = "BASE_TAKE_QUEST_SUCCEED"
|
||||
## Const of quest types
|
||||
const QUEST_TYPE = {
|
||||
Quest.Type.Elimination: "BASE_QUEST_ELIMINATION",
|
||||
Quest.Type.Delivery: "BASE_QUEST_DELIVERY"
|
||||
}
|
||||
## Const of restrictions
|
||||
const RESTRICTIONS = {
|
||||
Quest.Restriction.NoDeaths: "BASE_QUEST_RESTRICTION_NO_DEATHS",
|
||||
Quest.Restriction.NoWeapon: "BASE_QUEST_RESTRICTION_NO_WEAPON",
|
||||
|
|
@ -27,7 +35,7 @@ func fetch_quest():
|
|||
make_answer(quest)
|
||||
|
||||
func make_answer(quest: Quest):
|
||||
has_quest = quest != null
|
||||
var has_quest = quest != null
|
||||
if !has_quest:
|
||||
answer = tr(NO_QUEST)
|
||||
return
|
||||
|
|
@ -42,6 +50,15 @@ func make_answer(quest: Quest):
|
|||
for restriction in quest.restrictions:
|
||||
restrictions += tr(RESTRICTIONS[restriction]) + "\n"
|
||||
quest_format["restrictions"] = restrictions
|
||||
quest_format["reward"] = quest.reward_money
|
||||
var quest_info = tr(QUEST_TYPE[quest.type]).format(quest_format)
|
||||
var final_format = {"quest_info": quest_info}
|
||||
answer = tr(HAS_QUEST).format(final_format)
|
||||
|
||||
## Assigns quest to player by returning it and nullifying self quest
|
||||
func assign_to_player() -> Quest:
|
||||
quest.status = Quest.Status.Taken
|
||||
var temp_quest = quest
|
||||
quest = null
|
||||
make_answer(quest)
|
||||
return temp_quest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue