-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathBattleArena.cs
553 lines (494 loc) · 24.4 KB
/
BattleArena.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Bencodex.Types;
using Lib9c.Abstractions;
using Libplanet.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
using Nekoyume.Action.Guild.Migration.LegacyModels;
using Nekoyume.Arena;
using Nekoyume.Battle;
using Nekoyume.Exceptions;
using Nekoyume.Extensions;
using Nekoyume.Helper;
using Nekoyume.Model;
using Nekoyume.Model.Arena;
using Nekoyume.Model.BattleStatus.Arena;
using Nekoyume.Model.EnumType;
using Nekoyume.Model.Item;
using Nekoyume.Model.Stat;
using Nekoyume.Model.State;
using Nekoyume.Module;
using Nekoyume.TableData;
using Nekoyume.TableData.Rune;
using Serilog;
using static Lib9c.SerializeKeys;
namespace Nekoyume.Action
{
/// <summary>
/// Introduce at https://github.com/planetarium/lib9c/pull/2229
/// Changed at https://github.com/planetarium/lib9c/pull/2242
/// </summary>
[Serializable]
[ActionType("battle_arena15")]
public class BattleArena : GameAction, IBattleArenaV1
{
public const string PurchasedCountKey = "purchased_count_during_interval";
public const int HpIncreasingModifier = 5;
public Address myAvatarAddress;
public Address enemyAvatarAddress;
public int championshipId;
public int round;
public int ticket;
public List<Guid> costumes;
public List<Guid> equipments;
public List<RuneSlotInfo> runeInfos;
Address IBattleArenaV1.MyAvatarAddress => myAvatarAddress;
Address IBattleArenaV1.EnemyAvatarAddress => enemyAvatarAddress;
int IBattleArenaV1.ChampionshipId => championshipId;
int IBattleArenaV1.Round => round;
int IBattleArenaV1.Ticket => ticket;
IEnumerable<Guid> IBattleArenaV1.Costumes => costumes;
IEnumerable<Guid> IBattleArenaV1.Equipments => equipments;
IEnumerable<IValue> IBattleArenaV1.RuneSlotInfos => runeInfos
.Select(x => x.Serialize());
protected override IImmutableDictionary<string, IValue> PlainValueInternal =>
new Dictionary<string, IValue>()
{
[MyAvatarAddressKey] = myAvatarAddress.Serialize(),
[EnemyAvatarAddressKey] = enemyAvatarAddress.Serialize(),
[ChampionshipIdKey] = championshipId.Serialize(),
[RoundKey] = round.Serialize(),
[TicketKey] = ticket.Serialize(),
[CostumesKey] = new List(costumes
.OrderBy(element => element).Select(e => e.Serialize())),
[EquipmentsKey] = new List(equipments
.OrderBy(element => element).Select(e => e.Serialize())),
[RuneInfos] = runeInfos.OrderBy(x => x.SlotIndex).Select(x=> x.Serialize()).Serialize(),
}.ToImmutableDictionary();
protected override void LoadPlainValueInternal(
IImmutableDictionary<string, IValue> plainValue)
{
myAvatarAddress = plainValue[MyAvatarAddressKey].ToAddress();
enemyAvatarAddress = plainValue[EnemyAvatarAddressKey].ToAddress();
championshipId = plainValue[ChampionshipIdKey].ToInteger();
round = plainValue[RoundKey].ToInteger();
ticket = plainValue[TicketKey].ToInteger();
costumes = ((List) plainValue[CostumesKey]).Select(e => e.ToGuid()).ToList();
equipments = ((List) plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList();
runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List) x));
ValidateTicket();
}
public override IWorld Execute(IActionContext context)
{
GasTracer.UseGas(1);
ValidateTicket();
var states = context.PreviousState;
var addressesHex = GetSignerAndOtherAddressesHex(
context,
myAvatarAddress,
enemyAvatarAddress);
var started = DateTimeOffset.UtcNow;
Log.Debug("{AddressesHex}BattleArena exec started", addressesHex);
if (myAvatarAddress.Equals(enemyAvatarAddress))
{
throw new InvalidAddressException(
$"{addressesHex}Aborted as the signer tried to battle for themselves.");
}
if (!states.TryGetAvatarState(
context.Signer,
myAvatarAddress,
out var myAvatarState))
{
throw new FailedLoadStateException(
$"{addressesHex}Aborted as the avatar state of the signer was failed to load.");
}
var collectionStates =
states.GetCollectionStates(new[]{ myAvatarAddress, enemyAvatarAddress });
var collectionExist = collectionStates.Count > 0;
var sheetTypes = new List<Type>
{
typeof(ArenaSheet),
typeof(ItemRequirementSheet),
typeof(EquipmentItemRecipeSheet),
typeof(EquipmentItemSubRecipeSheetV2),
typeof(EquipmentItemOptionSheet),
typeof(MaterialItemSheet),
typeof(RuneListSheet),
typeof(RuneLevelBonusSheet),
typeof(BuffLimitSheet),
typeof(BuffLinkSheet),
};
if (collectionExist)
{
sheetTypes.Add(typeof(CollectionSheet));
}
var sheets = states.GetSheets(
containArenaSimulatorSheets: true,
sheetTypes: sheetTypes);
var gameConfigState = states.GetGameConfigState();
var (equipmentItems, costumeItems) = myAvatarState.ValidEquipmentAndCostumeV2(
costumes,
equipments,
sheets.GetSheet<ItemRequirementSheet>(),
sheets.GetSheet<EquipmentItemRecipeSheet>(),
sheets.GetSheet<EquipmentItemSubRecipeSheetV2>(),
sheets.GetSheet<EquipmentItemOptionSheet>(),
context.BlockIndex,
addressesHex,
gameConfigState);
// update my rune slot
var myRuneSlotStateAddress = RuneSlotState.DeriveAddress(myAvatarAddress, BattleType.Arena);
var myRuneSlotState = states.TryGetLegacyState(myRuneSlotStateAddress, out List rawRuneSlotState)
? new RuneSlotState(rawRuneSlotState)
: new RuneSlotState(BattleType.Arena);
var runeListSheet = sheets.GetSheet<RuneListSheet>();
myRuneSlotState.UpdateSlot(runeInfos, runeListSheet);
states = states.SetLegacyState(myRuneSlotStateAddress, myRuneSlotState.Serialize());
// update my item slot
var myItemSlotStateAddress = ItemSlotState.DeriveAddress(myAvatarAddress, BattleType.Arena);
var myItemSlotState = states.TryGetLegacyState(myItemSlotStateAddress, out List rawItemSlotState)
? new ItemSlotState(rawItemSlotState)
: new ItemSlotState(BattleType.Arena);
myItemSlotState.UpdateEquipment(equipments);
myItemSlotState.UpdateCostumes(costumes);
states = states.SetLegacyState(myItemSlotStateAddress, myItemSlotState.Serialize());
// check championship id and round in ArenaSheet.
var arenaSheet = sheets.GetSheet<ArenaSheet>();
if (!arenaSheet.TryGetValue(championshipId, out var arenaRow))
{
throw new SheetRowNotFoundException(nameof(ArenaSheet),
$"championship Id : {championshipId}");
}
if (!arenaRow.TryGetRound(round, out var roundData))
{
throw new RoundNotFoundException(
$"[{nameof(BattleArena)}] ChampionshipId({arenaRow.ChampionshipId}) - " +
$"round({round})");
}
if (!roundData.IsTheRoundOpened(context.BlockIndex))
{
throw new ThisArenaIsClosedException(
$"{nameof(BattleArena)} : block index({context.BlockIndex}) - " +
$"championshipId({roundData.ChampionshipId}) - round({roundData.Round})");
}
// check both myAvatarAddress and enemyAvatarAddress are joined in the current arena round.
var arenaParticipantsAddr = ArenaParticipants.DeriveAddress(roundData.ChampionshipId, roundData.Round);
if (!states.TryGetArenaParticipants(arenaParticipantsAddr, out var arenaParticipants))
{
throw new ArenaParticipantsNotFoundException(
$"[{nameof(BattleArena)}] ChampionshipId({roundData.ChampionshipId}) - " +
$"round({roundData.Round})");
}
if (!arenaParticipants.AvatarAddresses.Contains(myAvatarAddress))
{
throw new AddressNotFoundInArenaParticipantsException(
$"[{nameof(BattleArena)}] my avatar address : {myAvatarAddress}");
}
if (!arenaParticipants.AvatarAddresses.Contains(enemyAvatarAddress))
{
throw new AddressNotFoundInArenaParticipantsException(
$"[{nameof(BattleArena)}] enemy avatar address : {enemyAvatarAddress}");
}
// check last battle block index of my arena avatar state to prevent frequent battles.
var myArenaAvatarStateAddr = ArenaAvatarState.DeriveAddress(myAvatarAddress);
if (!states.TryGetArenaAvatarState(myArenaAvatarStateAddr, out var myArenaAvatarState))
{
throw new ArenaAvatarStateNotFoundException(
$"[{nameof(BattleArena)}] my avatar address : {myAvatarAddress}");
}
var battleArenaInterval = roundData.ArenaType == ArenaType.OffSeason
? 1
: gameConfigState.BattleArenaInterval;
if (context.BlockIndex - myArenaAvatarState.LastBattleBlockIndex < battleArenaInterval)
{
throw new CoolDownBlockException(
$"[{nameof(BattleArena)}] LastBattleBlockIndex : " +
$"{myArenaAvatarState.LastBattleBlockIndex} " +
$"CurrentBlockIndex : {context.BlockIndex}");
}
// check my arena score and enemy arena score are within an acceptable range to proceed with the battle.
var myArenaScoreAddr = ArenaScore.DeriveAddress(
myAvatarAddress,
roundData.ChampionshipId,
roundData.Round);
if (!states.TryGetArenaScore(myArenaScoreAddr, out var myArenaScore))
{
throw new ArenaScoreNotFoundException(
$"[{nameof(BattleArena)}] my avatar address : {myAvatarAddress}" +
$" - ChampionshipId({roundData.ChampionshipId}) - round({roundData.Round})");
}
var enemyArenaScoreAddr = ArenaScore.DeriveAddress(
enemyAvatarAddress,
roundData.ChampionshipId,
roundData.Round);
if (!states.TryGetArenaScore(enemyArenaScoreAddr, out var enemyArenaScore))
{
throw new ArenaScoreNotFoundException(
$"[{nameof(BattleArena)}] enemy avatar address : {enemyAvatarAddress}" +
$" - ChampionshipId({roundData.ChampionshipId}) - round({roundData.Round})");
}
if (!ArenaHelper.ValidateScoreDifference(
ArenaHelper.ScoreLimits,
roundData.ArenaType,
myArenaScore.Score,
enemyArenaScore.Score))
{
var scoreDiff = enemyArenaScore.Score - myArenaScore.Score;
throw new ValidateScoreDifferenceException(
$"[{nameof(BattleArena)}] Arena Type({roundData.ArenaType}) : " +
$"enemyScore({enemyArenaScore.Score}) - myScore({myArenaScore.Score}) = " +
$"diff({scoreDiff})");
}
var myArenaInformationAddr = ArenaInformation.DeriveAddress(
myAvatarAddress,
roundData.ChampionshipId,
roundData.Round);
if (!states.TryGetArenaInformation(myArenaInformationAddr, out var myArenaInformation))
{
throw new ArenaInformationNotFoundException(
$"[{nameof(BattleArena)}] my avatar address : {myAvatarAddress}" +
$" - ChampionshipId({roundData.ChampionshipId}) - round({roundData.Round})");
}
var purchasedCountAddr = myArenaInformation.Address.Derive(PurchasedCountKey);
if (!states.TryGetLegacyState(purchasedCountAddr, out Integer purchasedCountDuringInterval))
{
purchasedCountDuringInterval = 0;
}
var dailyArenaInterval = gameConfigState.DailyArenaInterval;
var currentTicketResetCount = ArenaHelper.GetCurrentTicketResetCount(
context.BlockIndex,
roundData.StartBlockIndex,
dailyArenaInterval);
if (myArenaInformation.TicketResetCount < currentTicketResetCount)
{
myArenaInformation.ResetTicket(currentTicketResetCount);
purchasedCountDuringInterval = 0;
states = states.SetLegacyState(purchasedCountAddr, purchasedCountDuringInterval);
}
if (roundData.ArenaType != ArenaType.OffSeason && ticket > 1)
{
throw new ExceedPlayCountException(
$"[{nameof(BattleArena)}] ticket : {ticket} / arenaType : {roundData.ArenaType}");
}
if (myArenaInformation.Ticket > 0)
{
myArenaInformation.UseTicket(ticket);
}
else if (ticket > 1)
{
throw new TicketPurchaseLimitExceedException(
$"[{nameof(ArenaInformation)}] tickets to buy : {ticket}");
}
else
{
var goldCurrency = states.GetGoldCurrency();
var ticketBalance =
ArenaHelper.GetTicketPrice(roundData, myArenaInformation, goldCurrency);
myArenaInformation.BuyTicket(roundData.MaxPurchaseCount);
if (purchasedCountDuringInterval >= roundData.MaxPurchaseCountWithInterval)
{
throw new ExceedTicketPurchaseLimitDuringIntervalException(
$"[{nameof(ArenaInformation)}] PurchasedTicketCount({purchasedCountDuringInterval}) >= MAX({{max}})");
}
purchasedCountDuringInterval++;
var feeAddress = states.GetFeeAddress(context.BlockIndex);
states = states
.TransferAsset(context, context.Signer, feeAddress, ticketBalance)
.SetLegacyState(purchasedCountAddr, purchasedCountDuringInterval);
}
// update my arena avatar state
myArenaAvatarState.UpdateEquipment(equipments);
myArenaAvatarState.UpdateCostumes(costumes);
myArenaAvatarState.LastBattleBlockIndex = context.BlockIndex;
var myRuneStates = states.GetRuneState(myAvatarAddress, out var migrateRequired);
if (migrateRequired)
{
states = states.SetRuneState(myAvatarAddress, myRuneStates);
}
// just validate
foreach (var runeSlotInfo in runeInfos)
{
myRuneStates.GetRuneState(runeSlotInfo.RuneId);
}
// get enemy equipped items
var enemyItemSlotStateAddress = ItemSlotState.DeriveAddress(enemyAvatarAddress, BattleType.Arena);
var enemyItemSlotState = states.TryGetLegacyState(enemyItemSlotStateAddress, out List rawEnemyItemSlotState)
? new ItemSlotState(rawEnemyItemSlotState)
: new ItemSlotState(BattleType.Arena);
var enemyRuneSlotStateAddress = RuneSlotState.DeriveAddress(enemyAvatarAddress, BattleType.Arena);
var enemyRuneSlotState = states.TryGetLegacyState(enemyRuneSlotStateAddress, out List enemyRawRuneSlotState)
? new RuneSlotState(enemyRawRuneSlotState)
: new RuneSlotState(BattleType.Arena);
var enemyRuneStates = states.GetRuneState(enemyAvatarAddress, out _);
// simulate
var myArenaPlayerDigest = new ArenaPlayerDigest(
myAvatarState,
equipments,
costumes,
myRuneStates,
myRuneSlotState);
var enemyAvatarState = states.GetEnemyAvatarState(enemyAvatarAddress);
var enemyArenaPlayerDigest = new ArenaPlayerDigest(
enemyAvatarState,
enemyItemSlotState.Equipments,
enemyItemSlotState.Costumes,
enemyRuneStates,
enemyRuneSlotState);
var previousMyScore = myArenaScore.Score;
var arenaSheets = sheets.GetArenaSimulatorSheets();
var buffLimitSheet = sheets.GetSheet<BuffLimitSheet>();
var winCount = 0;
var defeatCount = 0;
var rewards = new List<ItemBase>();
var random = context.GetRandom();
var collectionModifiers = new Dictionary<Address, List<StatModifier>>
{
[myAvatarAddress] = new(),
[enemyAvatarAddress] = new(),
};
if (collectionExist)
{
var collectionSheet = sheets.GetSheet<CollectionSheet>();
#pragma warning disable LAA1002
foreach (var (address, state) in collectionStates)
#pragma warning restore LAA1002
{
collectionModifiers[address] = state.GetModifiers(collectionSheet);
}
}
var buffLinkSheet = sheets.GetSheet<BuffLinkSheet>();
for (var i = 0; i < ticket; i++)
{
var simulator = new ArenaSimulator(random, HpIncreasingModifier,
gameConfigState.ShatterStrikeMaxDamage);
var log = simulator.Simulate(
myArenaPlayerDigest,
enemyArenaPlayerDigest,
arenaSheets,
collectionModifiers[myAvatarAddress],
collectionModifiers[enemyAvatarAddress],
buffLimitSheet,
buffLinkSheet,
true);
if (log.Result.Equals(ArenaLog.ArenaResult.Win))
{
winCount++;
}
else
{
defeatCount++;
}
var reward = RewardSelector.Select(
random,
sheets.GetSheet<WeeklyArenaRewardSheet>(),
sheets.GetSheet<MaterialItemSheet>(),
myArenaPlayerDigest.Level,
maxCount: ArenaHelper.GetRewardCount(previousMyScore));
rewards.AddRange(reward);
}
// add rewards
foreach (var itemBase in rewards.OrderBy(x => x.Id))
{
myAvatarState.inventory.AddItem(itemBase);
}
// add medals
if (roundData.ArenaType != ArenaType.OffSeason && winCount > 0)
{
if (roundData.MedalId == 0)
{
throw new MedalIdNotFoundException($"{addressesHex}{roundData.ChampionshipId}-{roundData.Round}.MedalId is zero. Need to set MedalId column at ArenaSheet.");
}
var materialSheet = sheets.GetSheet<MaterialItemSheet>();
var medal = ItemFactory.CreateMaterial(materialSheet, roundData.MedalId);
myAvatarState.inventory.AddItem(medal, count: winCount);
}
// update scores and record
var (myWinScore, myDefeatScore, enemyDefeatScore) =
ArenaHelper.GetScores(previousMyScore, enemyArenaScore.Score);
var myScore = (myWinScore * winCount) + (myDefeatScore * defeatCount);
myArenaScore.AddScore(myScore);
enemyArenaScore.AddScore(enemyDefeatScore * winCount);
myArenaInformation.UpdateRecord(winCount, defeatCount);
// start getting the total my CP from here.
var runeOptionSheet = sheets.GetSheet<RuneOptionSheet>();
var myRuneOptions = new List<RuneOptionSheet.Row.RuneOptionInfo>();
foreach (var runeInfo in myRuneSlotState.GetEquippedRuneSlotInfos())
{
if (!myRuneStates.TryGetRuneState(runeInfo.RuneId, out var runeState))
{
continue;
}
if (!runeOptionSheet.TryGetValue(runeState.RuneId, out var optionRow))
{
throw new SheetRowNotFoundException("RuneOptionSheet", runeState.RuneId);
}
if (!optionRow.LevelOptionMap.TryGetValue(runeState.Level, out var option))
{
throw new SheetRowNotFoundException("RuneOptionSheet", runeState.Level);
}
myRuneOptions.Add(option);
}
var characterSheet = sheets.GetSheet<CharacterSheet>();
if (!characterSheet.TryGetValue(myAvatarState.characterId, out var myCharacterRow))
{
throw new SheetRowNotFoundException("CharacterSheet", myAvatarState.characterId);
}
var costumeStatSheet = sheets.GetSheet<CostumeStatSheet>();
var runeLevelBonusSheet = sheets.GetSheet<RuneLevelBonusSheet>();
var myRuneLevelBonus = RuneHelper.CalculateRuneLevelBonus(myRuneStates, runeListSheet, runeLevelBonusSheet);
var myCp = CPHelper.TotalCP(
equipmentItems,
costumeItems,
myRuneOptions,
myAvatarState.level,
myCharacterRow,
costumeStatSheet,
collectionModifiers[myAvatarAddress],
myRuneLevelBonus);
// update myArenaParticipant: This is currently redundant, but we plan to replace all the ArenaScore and
// ArenaInformation states and some of the ArenaAvatarState states in the future.
// The reason we are creating a new ArenaParticipant instead of getting it and updating its state is to
// save resources on getting it since we already have most of the values.
var myArenaParticipant = new ArenaParticipant(myAvatarAddress)
{
Name = myAvatarState.name,
PortraitId = myAvatarState.GetPortraitId(),
Level = myAvatarState.level,
Cp = myCp,
Score = myArenaScore.Score,
Ticket = myArenaInformation.Ticket,
TicketResetCount = myArenaInformation.TicketResetCount,
PurchasedTicketCount = myArenaInformation.PurchasedTicketCount,
Win = myArenaInformation.Win,
Lose = myArenaInformation.Lose,
LastBattleBlockIndex = myArenaAvatarState.LastBattleBlockIndex,
};
states = states.SetArenaParticipant(championshipId, round, myAvatarAddress, myArenaParticipant);
// update enemyArenaParticipantState.Score
var enemyArenaParticipant = states.GetArenaParticipant(championshipId, round, enemyAvatarAddress);
if (enemyArenaParticipant is not null)
{
enemyArenaParticipant.Score = enemyArenaScore.Score;
states = states.SetArenaParticipant(championshipId, round, enemyAvatarAddress, enemyArenaParticipant);
}
var ended = DateTimeOffset.UtcNow;
Log.Debug("{AddressesHex}BattleArena Total Executed Time: {Elapsed}", addressesHex, ended - started);
return states
.SetLegacyState(myArenaAvatarStateAddr, myArenaAvatarState.Serialize())
.SetLegacyState(myArenaScoreAddr, myArenaScore.Serialize())
.SetLegacyState(enemyArenaScoreAddr, enemyArenaScore.Serialize())
.SetLegacyState(myArenaInformationAddr, myArenaInformation.Serialize())
.SetAvatarState(myAvatarAddress, myAvatarState);
}
private void ValidateTicket()
{
if (ticket <= 0)
{
throw new ArgumentException("ticket must be greater than 0");
}
}
}
}