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

Initial Card System Support #330

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SalmanTKhan
Copy link
Contributor

@SalmanTKhan SalmanTKhan commented Oct 10, 2024

  • Currently cards can be equipped/unequipped and synthesized to increase card level.
  • Loading and Saving Cards works via a Cards Table.
  • Added Item Properties Table (Save Card Level, Card Exp).

Card Effects aren't implemented yet.

* Currently cards can be equipped/unequipped and synthesized to increase card level.
* Loading and Saving Cards works via a Cards Table.
* Added Item Properties Table (Save Card Level, Card Exp).
@SalmanTKhan SalmanTKhan added the feature This issue is regarding the implementation of a new feature. label Oct 10, 2024
@SalmanTKhan SalmanTKhan requested a review from exectails October 10, 2024 16:47
@SalmanTKhan SalmanTKhan self-assigned this Oct 10, 2024
Copy link
Member

@exectails exectails left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. It doesn't look half bad, but I have a few notes.

src/Shared/Data/Database/ItemExp.cs Show resolved Hide resolved
/// <param name="idName"></param>
/// <param name="id"></param>
/// <param name="properties"></param>
protected void SaveProperties(string databaseName, string idName, long id, Properties properties, MySqlConnection conn, MySqlTransaction trans)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the current SaveProperties method already gets its own connection and transaction, we could easily call this from it and reduce the redundant code, right?

@@ -162,6 +162,8 @@ public Character GetCharacter(long accountId, long characterId)
}

this.LoadCharacterItems(character);
foreach (var card in this.LoadCharacterItems(character, "cards"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should probably be its own method, so there's not a loop in the middle of a series of Load calls.

@@ -423,6 +425,7 @@ public void SaveCharacter(Character character)
}

this.SaveCharacterItems(character);
this.SaveCharacterItems(character, "cards", character.Inventory.GetCards());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generalized item readers and writers aren't a bad idea, but they might be a bit difficult to handle, because items will usually have some unique values that you can't generalize, like the position for storage items or the status for mail items. Basically, this would turn into something rather complex, or we could just duplicate that little bit of code. I would suggest creating dedicated Load and SaveCards methods.


if (this.Data.CardGroup != CardGroup.None)
{
this.Properties.SetString(PropertyName.CardGroupName, this.Data.CardGroup.ToString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably mention the importance of the value names in the enum, so nobody gets any ideas about C#-ifying the naming scheme, which would break the property value.

system/scripts/zone/core/normal_tx.cs Show resolved Hide resolved
if (!character.Components.TryGet<TimeActionComponent>(out var timeAction))
return DialogTxResult.Fail;

var timeActionResult = timeAction.StartAsync("ItemCraftProcess", "None", "UPGRADEGEM", TimeSpan.FromSeconds(synthesisTime)).Result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Result on the task isn't ideal, because by executing this synchronously, you're putting the thread that is handling this request that came in via the network on pause until the time action returns. Granted, it's only a couple seconds, but we want to handle packets as quickly as possible.

I would recommend using Start and a callback instead, or create an additional async Task method that you call with CallSafe from this one, to more properly implement this asynchronous operation.

@@ -4474,5 +4484,17 @@ public static void ZC_ACTION_PKS(IActor toActor, IActor fromActor, byte type, in

toActor.Map.Broadcast(packet);
}

/// Cancel "timed action" due to mouse movement (walking)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a <summary> missing here. Also, could you clarify what exactly this does? The way you're using it, it doesn't seem related to mouse movement, and it's unclear to me what walking refers to in this context.

system/scripts/zone/core/normal_tx.cs Show resolved Hide resolved
/// <summary>
/// Gets or sets an expiration date on the item
/// </summary>
public DateTime ExpirationDate { get; private set; } = DateTime.MaxValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property doesn't appear to get used yet. Did you include it for future use and because of its use in IsExpired, which will never return true in the current code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was one of those partially cut out of the "card synthesis" code because I'm not sure if we want to go full property on the implementation or not. You can't use an expired material item to upgrade the card. I can remove the expiring item check till we decide what we want to do.

{ namespace: "Item", name: "LifeTime", type: "Number", id: 12614 }, { namespace: "Item", name: "ItemLifeTimeOver", type: "Number", id: 31586 }, { namespace: "Item", name: "ItemLifeTime", type: "String", id: 31587 },
LifeTime defines the duration (in seconds) (or if an item can expire)
ItemLifeTime is the "calculated" date of expiration
ItemLifeTimeOver is a (0 or 1) if the item is expired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue is regarding the implementation of a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants