Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fc-pregmod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pregmodfan
fc-pregmod
Commits
cb6a7d0c
Commit
cb6a7d0c
authored
3 years ago
by
Arkerthan
Browse files
Options
Downloads
Patches
Plain Diff
Fix it is possible to gain cash by repeatedly buying and selling shares of other arcologies
parent
7d3c7de5
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!10815
Fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/neighbor/neighborInteract.js
+39
-13
39 additions, 13 deletions
src/neighbor/neighborInteract.js
with
39 additions
and
13 deletions
src/neighbor/neighborInteract.js
+
39
−
13
View file @
cb6a7d0c
...
...
@@ -119,6 +119,7 @@ App.Neighbor.Interact = function() {
const
interact
=
(
function
()
{
let
nd
=
new
App
.
Neighbor
.
Display
((
id
)
=>
replaceDetails
(
id
));
const
DEMAND_PER_PERCENT
=
2
;
return
list
;
...
...
@@ -183,8 +184,7 @@ App.Neighbor.Interact = function() {
App
.
UI
.
DOM
.
appendNewElement
(
"
p
"
,
frag
,
`Your arcology's culture is capable of starting to exert cultural sway over other arcologies. It can project
${
desc
[
0
]}
.`
);
}
}
else
{
const
ownershipCost
=
500
*
Math
.
trunc
(
V
.
arcologies
[
arcID
].
prosperity
*
(
1
+
(
V
.
arcologies
[
arcID
].
demandFactor
/
100
)));
frag
.
append
(
`A 1% interest in this arcology is worth
${
cashFormat
(
ownershipCost
)}
. `
);
frag
.
append
(
`A 1% interest in this arcology is worth
${
cashFormat
(
buyValue
(
V
.
arcologies
[
arcID
],
1
))}
. `
);
if
(
V
.
arcologies
[
arcID
].
ownership
+
V
.
arcologies
[
arcID
].
PCminority
+
V
.
arcologies
[
arcID
].
minority
<
100
)
{
frag
.
append
(
`The transaction fee is
${
cashFormat
(
10000
)}
.`
);
}
...
...
@@ -192,18 +192,16 @@ App.Neighbor.Interact = function() {
if
(
V
.
arcologies
[
arcID
].
ownership
+
V
.
arcologies
[
arcID
].
PCminority
+
V
.
arcologies
[
arcID
].
minority
<
100
)
{
let
links
=
[];
links
.
push
(
App
.
UI
.
DOM
.
link
(
"
Buy
"
,
()
=>
{
cashX
(
forceNeg
(
ownershipCost
),
"
war
"
);
cashX
(
-
10000
,
"
war
"
);
cashX
(
-
(
buyValue
(
V
.
arcologies
[
arcID
],
1
)
+
10000
),
"
war
"
);
V
.
arcologies
[
arcID
].
PCminority
+=
1
;
V
.
arcologies
[
arcID
].
demandFactor
+=
2
;
V
.
arcologies
[
arcID
].
demandFactor
+=
DEMAND_PER_PERCENT
;
},
[],
"
Neighbor Interact
"
));
if
(
V
.
arcologies
[
arcID
].
ownership
+
V
.
arcologies
[
arcID
].
PCminority
+
V
.
arcologies
[
arcID
].
minority
<=
90
)
{
if
(
V
.
cash
>
ownershipCost
*
1
0
)
{
if
(
V
.
cash
>
buyValue
(
V
.
arcologies
[
arcID
],
10
)
+
1000
0
)
{
const
link
=
App
.
UI
.
DOM
.
link
(
"
10%
"
,
()
=>
{
cashX
(
forceNeg
(
ownershipCost
*
10
),
"
war
"
);
cashX
(
-
10000
,
"
war
"
);
cashX
(
-
(
buyValue
(
V
.
arcologies
[
arcID
],
10
)
+
10000
),
"
war
"
);
V
.
arcologies
[
arcID
].
PCminority
+=
10
;
V
.
arcologies
[
arcID
].
demandFactor
+=
2
0
;
V
.
arcologies
[
arcID
].
demandFactor
+=
DEMAND_PER_PERCENT
*
1
0
;
},
[],
"
Neighbor Interact
"
);
links
.
push
(
link
);
}
...
...
@@ -217,9 +215,9 @@ App.Neighbor.Interact = function() {
if
(
V
.
arcologies
[
arcID
].
PCminority
>
0
)
{
let
links
=
[];
links
.
push
(
App
.
UI
.
DOM
.
link
(
"
Sell
"
,
()
=>
{
cashX
(
ownershipCost
,
"
war
"
);
cashX
(
sellValue
(
V
.
arcologies
[
arcID
],
1
)
,
"
war
"
);
V
.
arcologies
[
arcID
].
PCminority
-=
1
;
V
.
arcologies
[
arcID
].
demandFactor
-=
2
;
V
.
arcologies
[
arcID
].
demandFactor
-=
DEMAND_PER_PERCENT
;
if
(
V
.
arcologies
[
arcID
].
government
!==
"
your agent
"
&&
V
.
arcologies
[
arcID
].
government
!==
"
your trustees
"
&&
V
.
arcologies
[
arcID
].
rival
!==
1
)
{
if
(
V
.
arcologies
[
arcID
].
ownership
+
V
.
arcologies
[
arcID
].
PCminority
+
V
.
arcologies
[
arcID
].
minority
<
10
)
{
V
.
arcologies
[
arcID
].
ownership
+=
10
;
...
...
@@ -229,9 +227,9 @@ App.Neighbor.Interact = function() {
},
[],
"
Neighbor Interact
"
));
if
(
V
.
arcologies
[
arcID
].
PCminority
>=
10
)
{
links
.
push
(
App
.
UI
.
DOM
.
link
(
"
10%
"
,
()
=>
{
cashX
(
(
ownershipCost
*
10
),
"
war
"
);
cashX
(
sellValue
(
V
.
arcologies
[
arcID
],
10
),
"
war
"
);
V
.
arcologies
[
arcID
].
PCminority
-=
10
;
V
.
arcologies
[
arcID
].
demandFactor
-=
2
0
;
V
.
arcologies
[
arcID
].
demandFactor
-=
DEMAND_PER_PERCENT
*
1
0
;
if
(
V
.
arcologies
[
arcID
].
government
!==
"
your agent
"
&&
V
.
arcologies
[
arcID
].
government
!==
"
your trustees
"
&&
V
.
arcologies
[
arcID
].
rival
!==
1
)
{
if
(
V
.
arcologies
[
arcID
].
ownership
+
V
.
arcologies
[
arcID
].
PCminority
+
V
.
arcologies
[
arcID
].
minority
<
10
)
{
V
.
arcologies
[
arcID
].
ownership
+=
10
;
...
...
@@ -273,6 +271,34 @@ App.Neighbor.Interact = function() {
return
frag
;
}
/**
* How much does it cost to buy x percent of a given arcology
* @param {FC.ArcologyState} arc
* @param {number} percent
* @returns {number}
*/
function
buyValue
(
arc
,
percent
)
{
const
baseValue
=
500
*
arc
.
prosperity
;
// scale the demand in such a way that buying twice in a row costs the same as buying double once.
const
scaledDemand
=
arc
.
demandFactor
+
(
DEMAND_PER_PERCENT
*
(
percent
/
2
));
const
scalingFactor
=
1
+
(
scaledDemand
/
100
);
return
Math
.
round
(
baseValue
*
scalingFactor
*
percent
);
}
/**
* How much does the player get when selling x percent of a given arcology
* @param {FC.ArcologyState} arc
* @param {number} percent
* @returns {number}
*/
function
sellValue
(
arc
,
percent
)
{
const
baseValue
=
500
*
arc
.
prosperity
;
// scale the demand in such a way that selling twice in a row gives the same as selling double once.
const
scaledDemand
=
arc
.
demandFactor
-
(
DEMAND_PER_PERCENT
*
(
percent
/
2
));
const
scalingFactor
=
1
+
(
scaledDemand
/
100
);
return
Math
.
round
(
baseValue
*
scalingFactor
*
percent
);
}
/** Create a div containing actions specific to arcologies that are under the player's control
* @param {number} arcID
* @returns {Element}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment