Skip to content

Commit 365ca32

Browse files
authored
Merge pull request #384 from Nashet/dev
Dev
2 parents 2307042 + 1469b74 commit 365ca32

25 files changed

+74
-54
lines changed

Assets/EconomicSimulation/Scripts/Logic/Factory.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,14 @@ internal void setPriority(Priority priority)
348348
}
349349
public Procent getMargin()
350350
{
351-
if (getCountry().economy.getValue() == Economy.PlannedEconomy)
351+
if (getCountry().economy.getValue() == Economy.PlannedEconomy || !isWorking())
352352
return Procent.ZeroProcent;
353353
else
354354
{
355355
var divider = Game.market.getCost(getUpgradeNeeds()).get() * level;
356356
if (divider == 0f)
357-
Debug.Log("Division by zero in getMargin()");
358-
return new Procent(getProfit() / (divider), false);
357+
Debug.Log("Division by zero in getMargin()");
358+
return Procent.makeProcent(getProfit(), divider, false);
359359
}
360360
}
361361
internal Value getReopenCost()
@@ -509,9 +509,9 @@ public void ChangeSalary()
509509
salaryRaise = 0.003f;
510510
else if (margin.get() > 0.1f) //10%
511511
salaryRaise = 0.002f;
512-
513-
514-
512+
513+
514+
515515
salary.add(salaryRaise);
516516
}
517517

@@ -525,7 +525,7 @@ public void ChangeSalary()
525525
if (unemployment.isBiggerThan(Options.ProvinceExcessWorkforce))
526526
salary.subtract(0.001f, false);
527527

528-
if ( getWorkForce() == 0)// && getInputFactor() == 1)
528+
if (getWorkForce() == 0)// && getInputFactor() == 1)
529529
salary.set(getProvince().getLocalMinSalary());
530530
// to help factories catch up other factories salaries
531531
// salary.set(province.getLocalMinSalary());
@@ -752,7 +752,7 @@ internal void payDividend()
752752

753753

754754
}
755-
}
755+
}
756756

757757
internal void close()
758758
{
@@ -926,9 +926,9 @@ override public void consumeNeeds()
926926

927927
if (getCountry().economy.getValue() == Economy.PlannedEconomy)
928928
{
929-
if (daysInConstruction >= Options.fabricConstructionTimeWithoutCapitalism)
929+
if (daysInConstruction >= Options.fabricConstructionTimeWithoutCapitalism)
930930
if (getCountry().countryStorageSet.has(constructionNeeds))
931-
isBuyingComplete = getCountry().countryStorageSet.send(this.getInputProductsReserve(), constructionNeeds);
931+
isBuyingComplete = getCountry().countryStorageSet.send(this.getInputProductsReserve(), constructionNeeds);
932932
}
933933
else
934934
{
@@ -973,10 +973,7 @@ override internal float getExpences()
973973
{
974974
return base.getExpences() + getSalaryCost();
975975
}
976-
/// <summary>
977-
/// Should optimize? Seek for changes..
978-
/// </summary>
979-
/// <returns></returns>
976+
//Not necessary ti optimize - cost 0.1% of tick
980977
public int getWorkForce()
981978
{
982979
int result = 0;

Assets/EconomicSimulation/Scripts/Logic/Game.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,25 @@ internal static bool isPlayerSurrended()
321321

322322
static void generateMapImage()
323323
{
324+
int mapSize;
325+
int width;
324326
//#if UNITY_WEBGL
325-
int mapSize = 20000;//30000;
326-
int width = 150 + Random.Next(60); // 140 is sqrt of 20000
327-
//int width = 30 + Random.Next(12); // 140 is sqrt of 20000
328-
//#else
329-
// int mapSize = 40000;
330-
// int width = 200 + Random.Next(80);
331-
//#endif
327+
if (devMode)
328+
{
329+
mapSize = 20000;
330+
width = 150 + Random.Next(60);
331+
}
332+
else
333+
{
334+
mapSize = 25000;
335+
width = 170 + Random.Next(65);
336+
}
337+
// 140 is sqrt of 20000
338+
//int width = 30 + Random.Next(12); // 140 is sqrt of 20000
339+
//#else
340+
// int mapSize = 40000;
341+
// int width = 200 + Random.Next(80);
342+
//#endif
332343
Texture2D mapImage = new Texture2D(width, mapSize / width); // standard for webGL
333344

334345

@@ -474,7 +485,8 @@ static void makeHelloMessage()
474485
+ "\n\nOr, You can give control to AI and watch it"
475486
+ "\n\nTry arrows or WASD for scrolling map and mouse wheel for scale"
476487
+ "\n'Enter' key to close top window, space - to pause \\ unpause"
477-
+ "\n\n\nAlso I have now Patreon page where I post about that game development. Try red button below!"
488+
+ "\n\n\nI have now Patreon page where I post about that game development. Try red button below!"
489+
+ "\nAlso I would be thankful if you will share info about this project"
478490
, "Ok");
479491
}
480492

@@ -533,10 +545,10 @@ internal static void simulate()
533545
factory.produce();
534546
factory.payTaxes(); // empty for now
535547
}
536-
foreach (PopUnit pop in province.allPopUnits)
548+
foreach (PopUnit pop in province.allPopUnits)
537549
pop.produce();
538550
}
539-
551+
540552
// big CONCUME circle
541553
foreach (Country country in Country.getAllExisting())
542554
{
@@ -576,7 +588,7 @@ internal static void simulate()
576588
pop.payTaxToAllAristocrats();
577589
}
578590
foreach (PopUnit pop in province.allPopUnits)
579-
{
591+
{
580592
pop.consumeNeeds();
581593
}
582594
}
@@ -615,7 +627,7 @@ internal static void simulate()
615627
soldier.takePayCheck();
616628
}
617629
//because income come only after consuming, and only after FULL consumption
618-
if ( pop.canTrade() && pop.hasToPayGovernmentTaxes())
630+
if (pop.canTrade() && pop.hasToPayGovernmentTaxes())
619631
// POps who can't trade will pay tax BEFORE consumption, not after
620632
// Otherwise pops who can't trade avoid tax
621633
pop.payTaxes();

Assets/EconomicSimulation/Scripts/Logic/Interfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEditor;
2+
33

44
namespace Nashet.EconomicSimulation
55
{

Assets/EconomicSimulation/Scripts/Logic/Market.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ private Storage recalculateProductForConsumers(Product product, Func<Consumer, S
101101
foreach (Province province in country.ownedProvinces)
102102
foreach (Consumer consumer in province.getAllAgents())
103103
{
104-
Storage re = selector(consumer).getFirstStorage(product);
105-
result.add(re);
104+
Storage found = selector(consumer).getFirstStorage(product);
105+
result.add(found);
106106
}
107107
Storage countryStor = selector(country).getFirstStorage(product);
108108
result.add(countryStor);

Assets/EconomicSimulation/Scripts/Logic/PopTypes/Aristocrats.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEditor;
2+
33
using Nashet.ValueSpace;
44
using Nashet.Utils;
55

Assets/EconomicSimulation/Scripts/Logic/PopTypes/Artisans.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEditor;
2+
33
using Nashet.ValueSpace;
44
using System.Collections.Generic;
55

Assets/EconomicSimulation/Scripts/Logic/PopTypes/Capitalists.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEditor;
2+
33
using Nashet.ValueSpace;
44
using System.Linq;
55
using Nashet.Utils;

Assets/EconomicSimulation/Scripts/Logic/PopTypes/Farmers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEditor;
2+
33
using Nashet.ValueSpace;
44

55
namespace Nashet.EconomicSimulation

Assets/EconomicSimulation/Scripts/Logic/PopTypes/Investor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//using UnityEngine;
2-
//using UnityEditor;
2+
//
33
//using System;
44
//using Nashet.Utils;
55
//using Nashet.ValueSpace;

Assets/EconomicSimulation/Scripts/Logic/PopTypes/PopUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ private List<Storage> getNeedsInCommon(List<Storage> needs)
445445
Value multiplier = new Value(this.getPopulation() / 1000f);
446446
List<Storage> result = new List<Storage>();
447447
foreach (Storage next in needs)
448-
if (next.getProduct().isInventedByAnyOne())
448+
if (next.getProduct().IsInventedByAnyOne())
449449
{
450450
Storage nStor = new Storage(next.getProduct(), next.get());
451451
nStor.multiply(multiplier);

0 commit comments

Comments
 (0)