Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ShopTransaction Class Reference
Inheritance diagram for ShopTransaction:
EClass

Classes

class  Item
 

Public Member Functions

void Log ()
 
bool HasBought (Thing t)
 
bool CanSellBack (Thing t, int num=-1)
 
void Process (Thing t, int n, bool sell)
 
int GetPrice (Thing t, int n, bool sell)
 
void OnEndTransaction ()
 

Public Attributes

InvOwner trader
 
List< Itembought = new List<Item>()
 
List< Itemsold = new List<Item>()
 

Static Public Attributes

static ShopTransaction current
 
- Static Public Attributes inherited from EClass
static Core core
 

Additional Inherited Members

- Static Public Member Functions inherited from EClass
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 4 of file ShopTransaction.cs.

Member Function Documentation

◆ CanSellBack()

bool ShopTransaction.CanSellBack ( Thing  t,
int  num = -1 
)
inline

Definition at line 47 of file ShopTransaction.cs.

48 {
49 if (num == -1)
50 {
51 num = t.Num;
52 }
53 foreach (Item item in bought)
54 {
55 if (item.thing == t && item.num >= num)
56 {
57 return true;
58 }
59 }
60 return false;
61 }
int Num
Definition: Card.cs:154
List< Item > bought

References bought, item, and Card.Num.

Referenced by InvOwner.Transaction.IsValid(), InvOwner.ListInteractions(), and InvOwner.OnWriteNote().

◆ GetPrice()

int ShopTransaction.GetPrice ( Thing  t,
int  n,
bool  sell 
)
inline

Definition at line 115 of file ShopTransaction.cs.

116 {
117 long num = t.GetPrice(trader.currency, sell: false, trader.priceType);
118 long num2 = t.GetPrice(trader.currency, sell: true, trader.priceType);
119 int num3 = n;
120 long num4 = 0L;
121 long num5 = (sell ? num : num2);
122 foreach (Item item in sell ? bought : sold)
123 {
124 if (item.thing.id == t.id && item.price == num5)
125 {
126 int num6 = ((item.num >= num3) ? num3 : item.num);
127 num3 -= num6;
128 num4 += num6 * num5;
129 }
130 if (num3 == 0)
131 {
132 break;
133 }
134 }
135 num4 += (sell ? num2 : num) * num3;
136 if (num4 >= int.MaxValue || num4 <= -2147483647)
137 {
138 return -1;
139 }
140 return (int)num4;
141 }
string id
Definition: Card.cs:31
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:6449
CurrencyType currency
Definition: InvOwner.cs:532
PriceType priceType
Definition: InvOwner.cs:534
List< Item > sold

References bought, InvOwner.currency, Card.GetPrice(), item, InvOwner.priceType, sold, and trader.

Referenced by InvOwner.GetPrice().

◆ HasBought()

bool ShopTransaction.HasBought ( Thing  t)
inline

Definition at line 35 of file ShopTransaction.cs.

36 {
37 foreach (Item item in bought)
38 {
39 if (item.thing == t)
40 {
41 return true;
42 }
43 }
44 return false;
45 }

References bought, and item.

Referenced by InvOwner.Transaction.IsValid().

◆ Log()

void ShopTransaction.Log ( )
inline

Definition at line 23 of file ShopTransaction.cs.

24 {
25 foreach (Item item3 in bought)
26 {
27 Debug.Log("Bought:" + item3.thing.Name + "/" + item3.num + " x " + item3.price + " = " + item3.num * item3.price);
28 }
29 foreach (Item item4 in sold)
30 {
31 Debug.Log("Sold:" + item4.thing.Name + "/" + item4.num + " x " + item4.price + " = " + item4.num * item4.price);
32 }
33 }

References bought, Debug, Card.Name, ShopTransaction.Item.num, ShopTransaction.Item.price, sold, and ShopTransaction.Item.thing.

Referenced by Process().

◆ OnEndTransaction()

void ShopTransaction.OnEndTransaction ( )
inline

Definition at line 143 of file ShopTransaction.cs.

144 {
145 Thing thing = trader.owner.things.Find("chest_merchant");
146 if (thing != null)
147 {
148 thing.c_lockLv = 1;
149 }
150 foreach (Item item4 in bought)
151 {
152 Debug.Log(item4.thing);
153 item4.thing.SetInt(101);
154 item4.thing.isStolen = false;
155 }
156 if (trader.currency != CurrencyType.Money)
157 {
158 current = null;
159 return;
160 }
161 int num = 0;
162 foreach (Item item5 in bought)
163 {
164 for (int i = 0; i < item5.num; i++)
165 {
166 num += (int)Mathf.Sqrt(Mathf.Abs(item5.price * 5));
167 }
168 if (item5.thing.trait is TraitDeed)
169 {
170 EClass.player.flags.landDeedBought += item5.num;
171 }
172 }
173 if (num >= 10)
174 {
175 EClass.pc.ModExp(291, num);
176 }
177 Debug.Log("negotiation total:" + num);
178 num = 0;
179 foreach (Item item6 in sold)
180 {
181 if (item6.thing.isStolen)
182 {
183 item6.thing.isStolen = false;
184 for (int j = 0; j < item6.num; j++)
185 {
186 num += (int)Mathf.Sqrt(item6.price) / 2;
187 }
188 }
189 }
190 Debug.Log("stolen total:" + num);
191 if (num > 0)
192 {
194 }
195 current = null;
196 }
CurrencyType
Definition: CurrencyType.cs:2
ThingContainer things
Definition: Card.cs:34
void ModExp(string alias, int a)
Definition: Card.cs:2508
Definition: EClass.cs:5
static Chara pc
Definition: EClass.cs:14
void AddContribution(int a)
Definition: FACTION.cs:316
Definition: Guild.cs:2
static GuildThief Thief
Definition: Guild.cs:27
Card owner
Definition: InvOwner.cs:538
static ShopTransaction current
Thing Find(int uid)
Definition: Thing.cs:8

References Faction.AddContribution(), bought, InvOwner.currency, current, Debug, ThingContainer.Find(), Card.isStolen, Card.ModExp(), ShopTransaction.Item.num, InvOwner.owner, EClass.pc, ShopTransaction.Item.price, BaseCard.SetInt(), sold, Guild.Thief, ShopTransaction.Item.thing, Card.things, trader, and Card.trait.

Referenced by LayerInventory.CreateBuy().

◆ Process()

void ShopTransaction.Process ( Thing  t,
int  n,
bool  sell 
)
inline

Definition at line 63 of file ShopTransaction.cs.

64 {
65 int price = t.GetPrice(trader.currency, sell: false, trader.priceType);
66 int price2 = t.GetPrice(trader.currency, sell: true, trader.priceType);
67 int num = n;
68 Debug.Log((sell ? "■Selling:" : "■Buying:") + t.Name + "/" + n + " x " + (sell ? price2 : price) + " = " + n * (sell ? price2 : price));
69 int num2 = (sell ? price : price2);
70 List<Item> list = (sell ? bought : sold);
71 foreach (Item item in list)
72 {
73 if (item.thing.id == t.id && item.price == num2)
74 {
75 int num3 = ((item.num >= num) ? num : item.num);
76 num -= num3;
77 item.num -= num3;
78 }
79 if (num == 0)
80 {
81 break;
82 }
83 }
84 list.ForeachReverse(delegate(Item i)
85 {
86 if (i.num == 0)
87 {
88 list.Remove(i);
89 }
90 });
91 if (num > 0)
92 {
93 if (sell)
94 {
95 sold.Add(new Item
96 {
97 thing = t,
98 num = num,
99 price = price2
100 });
101 }
102 else
103 {
104 bought.Add(new Item
105 {
106 thing = t,
107 num = num,
108 price = price
109 });
110 }
111 }
112 Log();
113 }
string Name
Definition: Card.cs:2013

References bought, InvOwner.currency, Debug, Card.GetPrice(), item, Log(), Card.Name, ShopTransaction.Item.num, InvOwner.priceType, sold, and trader.

Referenced by InvOwner.Transaction.Process().

Member Data Documentation

◆ bought

List<Item> ShopTransaction.bought = new List<Item>()

Definition at line 19 of file ShopTransaction.cs.

Referenced by CanSellBack(), GetPrice(), HasBought(), Log(), OnEndTransaction(), and Process().

◆ current

◆ sold

List<Item> ShopTransaction.sold = new List<Item>()

Definition at line 21 of file ShopTransaction.cs.

Referenced by GetPrice(), Log(), OnEndTransaction(), and Process().

◆ trader

InvOwner ShopTransaction.trader

Definition at line 17 of file ShopTransaction.cs.

Referenced by GetPrice(), OnEndTransaction(), and Process().


The documentation for this class was generated from the following file: