This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathPiggyBank.cs
75 lines (72 loc) · 2.17 KB
/
PiggyBank.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
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Tremor
{
class PiggyBank : GlobalItem
{
public bool ManySimilarItems(Item item, Item[] inventory)
{
int count = inventory.ToList().Where(x => x.type == item.type).Count();
return count >= 2;
}
public int GetSimilarItemsStack(Item item, Item[] inventory)
{
int stack = 0;
for (int i = 0; i < inventory.Length; i++)
{
if (inventory[i].type == item.type)
{
stack += inventory[i].stack;
}
}
return stack;
}
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
{
Player player = Main.player[Main.myPlayer];
int[] coins = {
ItemID.CopperCoin,
ItemID.SilverCoin,
ItemID.GoldCoin,
ItemID.PlatinumCoin
};
if (item.type == ItemID.PiggyBank || item.type == ItemID.MoneyTrough)
{
foreach (Item myItem in player.bank.item)
{
if (!myItem.IsAir && coins.Contains(myItem.type))
{
if (!ManySimilarItems(myItem, player.bank.item))
{
tooltips.Add(new TooltipLine(mod, "", "[i/s1:" + myItem.type + " ]" + "" + " x" + myItem.stack + ""));
}
else if (!(tooltips.Where(tooltip => tooltip.text == "[i/s1:" + myItem.type + " ]" + "" + " x" + GetSimilarItemsStack(myItem, player.bank.item) + "").Count() > 0))
{
tooltips.Add(new TooltipLine(mod, "", "[i/s1:" + myItem.type + " ]" + "" + " x" + GetSimilarItemsStack(myItem, player.bank.item) + ""));
}
}
}
}
if (item.type == ItemID.Safe)
{
foreach (Item myItem in player.bank2.item)
{
if (!myItem.IsAir && coins.Contains(myItem.type))
{
if (!ManySimilarItems(myItem, player.bank2.item))
{
tooltips.Add(new TooltipLine(mod, "", "[i/s1:" + "" + " ]" + "" + " x" + myItem.stack + ""));
}
else if (!(tooltips.Where(tooltip => tooltip.text == "[i/s1:" + myItem.type + " ]" + "" + " x" + GetSimilarItemsStack(myItem, player.bank2.item) + "").Count() > 0))
{
tooltips.Add(new TooltipLine(mod, "", "[i/s1:" + "" + " ]" + "" + " x" + GetSimilarItemsStack(myItem, player.bank2.item) + ""));
}
}
}
}
}
}
}