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

👻 Restore unity methods #2503

Merged
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions Lib9c/Action/CreateAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
using System.Linq;
using System.Text.RegularExpressions;
using Bencodex.Types;
using Lib9c;
using Lib9c.Abstractions;
using Libplanet.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Nekoyume.Extensions;
using Nekoyume.Helper;
using Nekoyume.Model.Item;
using Nekoyume.Model.Stat;
using Nekoyume.Model.State;
Expand Down Expand Up @@ -343,6 +345,53 @@ public static AvatarState CreateAvatarState(string name,
return avatarState;
}

#if LIB9C_DEV_EXTENSIONS || UNITY_EDITOR
private static IWorld AddRunesForTest(
IActionContext context,
Address avatarAddress,
IWorld states,
int count = int.MaxValue)
{
var runeSheet = states.GetSheet<RuneSheet>();
foreach (var row in runeSheet.Values)
{
var rune = RuneHelper.ToFungibleAssetValue(row, count);
states = states.MintAsset(context, avatarAddress, rune);
}
return states;
}

private static IWorld AddSoulStoneForTest(
IActionContext context,
Address avatarAddress,
IWorld states,
int count = int.MaxValue)
{
var petSheet = states.GetSheet<PetSheet>();
foreach (var row in petSheet.Values)
{
var soulStone = Currencies.GetSoulStone(row.SoulStoneTicker) * count;
states = states.MintAsset(context, avatarAddress, soulStone);
}
return states;
}

private static IWorld AddPetsForTest(
Address avatarAddress,
IWorld states)
{
var petSheet = states.GetSheet<PetSheet>();
foreach (var id in petSheet.Keys)
{
var petState = new PetState(id);
petState.LevelUp();
var petStateAddress = PetState.DeriveAddress(avatarAddress, id);
states = states.SetLegacyState(petStateAddress, petState.Serialize());
}

return states;
}

private static void AddItemsForTest(
AvatarState avatarState,
IRandom random,
Expand Down Expand Up @@ -451,5 +500,6 @@ private static HashSet<int> AddOption(

return optionIds;
}
#endif
}
}
Loading