Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(code): Permanent changes to the player's ship via conversation actions. #190

Open
wants to merge 31 commits into
base: experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1cbba25
Adding a few explanatory comments, also makes these lines a touch eas…
Zitchas Jan 3, 2025
fedfe4d
Creating a map of attribute modifications
Zitchas Jan 4, 2025
4b44f91
size to Size
Zitchas Jan 4, 2025
9be1f5c
missing ()
Zitchas Jan 4, 2025
b131c7a
Test job and test error check
Zitchas Jan 5, 2025
e781e06
add missing space.
Zitchas Jan 5, 2025
2207a20
This looks like it creates the map...
Zitchas Jan 6, 2025
e40733a
Removed comment and added line to GameAction::Save
Zitchas Jan 6, 2025
a9543bf
Merge branch 'experimental' into f(c)-ESD-PermAttr-in-Convo_v2
Zitchas Jan 8, 2025
0ea0d32
Progress.... I think.
Zitchas Jan 9, 2025
ec4b302
It's on L253 now, not L267
Zitchas Jan 9, 2025
491f119
Removing the L342 log that gummed up things.
Zitchas Jan 9, 2025
df065ea
Progress!
Zitchas Jan 10, 2025
d2f31c8
It works!
Zitchas Jan 10, 2025
1d47ebd
safety checks
Zitchas Jan 11, 2025
cd3e9eb
fixes
Zitchas Jan 11, 2025
b0cd869
Adding "set"
Zitchas Jan 12, 2025
3561e4b
Part 2.
Zitchas Jan 12, 2025
c473b6e
Additional testing jobs, and work on safeties
Zitchas Jan 12, 2025
3e592fc
Update to the job.,
Zitchas Jan 13, 2025
ab78bba
More test, and working except for certain safeties
Zitchas Jan 13, 2025
e2f3206
Need to add shields to these bulk tests.
Zitchas Jan 13, 2025
715198b
ensuring shields are changed too.
Zitchas Jan 13, 2025
daedf7b
Everything's working except Mass and Cost. Those only take effect aft…
Zitchas Jan 14, 2025
4255ad8
Special handling for Modify Mass, works nicely.
Zitchas Jan 16, 2025
d5effdb
SetMass (and GetMass) now appear to be working!)
Zitchas Jan 16, 2025
d4df672
Set mass now works.
Zitchas Jan 16, 2025
399f38e
Remove unneeded error tracing & logging code
Zitchas Jan 16, 2025
ae41198
Fixes
Zitchas Jan 17, 2025
b870f8b
Merge branch 'experimental' into f(c)-ESD-PermAttr-in-Convo_v2
Zitchas Jan 20, 2025
5bb0f79
Merge branch 'experimental' into f(c)-ESD-PermAttr-in-Convo_v2
Zitchas Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions source/GameAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,24 @@
fail.insert(child.Token(1));
else if(key == "fail")
failCaller = true;
else if(key == "attributes")
{
// Current expected format is attributes add/set <attribute name> <value>
if(child.Size() == 4)
{
if(child.Token(1) == "add")
{
double valueChange = static_cast<double>(child.Value(3));
modifyAttributes[Get(child.Token(2))] = valueChange;

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / Linux

‘Get’ was not declared in this scope; did you mean ‘Set’?

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / Windows

'Get' was not declared in this scope; did you mean 'Set'?

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / MacOS

use of undeclared identifier 'Get'; did you mean 'get'?

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / MacOS

no matching function for call to 'get'

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu (22.04, GLES)

‘Get’ was not declared in this scope; did you mean ‘Set’?

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / MacOS

use of undeclared identifier 'Get'; did you mean 'get'?

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / MacOS

no matching function for call to 'get'

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / MacOS-ARM

use of undeclared identifier 'Get'; did you mean 'get'?

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / MacOS-ARM

no matching function for call to 'get'

Check failure on line 237 in source/GameAction.cpp

View workflow job for this annotation

GitHub Actions / Windows

'Get' was not declared in this scope; did you mean 'Set'?
Zitchas marked this conversation as resolved.
Show resolved Hide resolved
}
}
else if(child.Size() > 4)
child.PrintTrace("Error: Skipping \"attributes\" as >4 values is not yet supported:");
else
child.PrintTrace("Error: Skipping invalid values for \"attributes\":");
/*else if(child.Token(1) == "set")*/
/* < code to put the attributes into the set map, to be done after the add is working > ;*/
}
else
conditions.Add(child);
}
Expand Down Expand Up @@ -377,9 +395,17 @@



const map<std::string, double> &GameAction::ModifyAttributes() const noexcept
{
return modifyAttributes;
}



// Perform the specified tasks.
void GameAction::Do(PlayerInfo &player, UI *ui, const Mission *caller) const
{
// Log entries
if(!logText.empty())
player.AddLogEntry(logText);
for(auto &&it : specialLogText)
Expand All @@ -396,15 +422,19 @@

// If multiple outfits, ships are being transferred, first remove the ships,
// then the outfits, before adding any new ones.
// Removing ships.
for(auto &&it : giftShips)
if(!it.Giving())
it.Do(player);
// Take outfits.
for(auto &&it : giftOutfits)
if(it.second < 0)
DoGift(player, it.first, it.second, ui);
// Give outfits.
for(auto &&it : giftOutfits)
if(it.second > 0)
DoGift(player, it.first, it.second, ui);
// Give ships.
for(auto &&it : giftShips)
if(it.Giving())
it.Do(player);
Expand All @@ -425,14 +455,17 @@
// then this action won't offer, so MissionAction payment behavior
// is unchanged.
}
// giving the player a fine.
if(fine)
player.Accounts().AddFine(fine);
for(const auto &debtEntry : debt)
player.Accounts().AddDebt(debtEntry.amount, debtEntry.interest, debtEntry.term);

// Trigger events.
for(const auto &it : events)
player.AddEvent(*it.first, player.GetDate() + it.second.first);

// Mark and unmark systems.
for(const System *system : mark)
caller->Mark(system);
for(const System *system : unmark)
Expand Down
4 changes: 4 additions & 0 deletions source/GameAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class GameAction {
const std::map<const Outfit *, int> &Outfits() const noexcept;
const std::vector<ShipManager> &Ships() const noexcept;

// references the map of attributes to be changed.
const std::map<std::string, double> &ModifyAttributes() const noexcept;

// Perform this action.
void Do(PlayerInfo &player, UI *ui, const Mission *caller) const;

Expand Down Expand Up @@ -94,6 +97,7 @@ class GameAction {
std::map<const GameEvent *, std::pair<int, int>> events;
std::vector<ShipManager> giftShips;
std::map<const Outfit *, int> giftOutfits;
std::map<std::string, double> modifyAttributes;

int64_t payment = 0;
int64_t paymentMultiplier = 0;
Expand Down
Loading