Skip to content

Commit

Permalink
♻️ Refactor and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
matshou committed Jan 12, 2020
1 parent 8a7dcf6 commit 96e90f3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 45 deletions.
13 changes: 1 addition & 12 deletions common/buildings/00_buildings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,8 @@ courthouse = {
cost = 100
time = 12

# Note that we cannot use a scripted trigger to validate this
# as vanilla code does not recognize references to building entries
# that are made AFTER the calling building. In this situation the town hall
# building would not be recognized because it's declared after courthouse
#
trigger = {
is_state = yes
NOT = {
any_province_in_state = {
NOT = { province_id = PREV }
OR = { has_building = courthouse has_building = town_hall }
}
}
can_build_adm_center = yes
}

modifier = {
Expand Down
5 changes: 2 additions & 3 deletions common/scripted_effects/eve_core_scripts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ core.on_monthly_pulse = {
core.global_update = yes
}

states.update_all = yes
states.update_non_states = yes
#core.update_policies = yes
states.update_states = yes
states.update_territories = yes
autonomy.check_for_change = yes
vassals.update = yes

Expand Down
44 changes: 16 additions & 28 deletions common/scripted_effects/eve_state_scripts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,27 @@
# Update all states and provinces belonging to states
# @scope country
#
states.update_all = {

# reset state administration modifier so we can recalculate it
set_variable = { which = policy_gov_state_m value = 0 }
states.update_states = {

every_owned_province = {
limit = { is_state = yes }

# This scope will be entered once for each state
# This scope will be entered ONCE for each state
if = {
limit = { NOT = { has_province_flag = state_prov_updated } }
states.update_state = yes
}

clr_province_flag = state_prov_updated

owner = {
if = {
limit = { has_country_flag = adm_center_in_state }
update_state = yes
owner = {
if = {
limit = { NOT = { has_country_flag = adm_center_found } }
PREV = { states.remove_jurisdiction = yes }
limit = { has_country_flag = adm_center_in_state }
if = {
limit = { NOT = { has_country_flag = adm_center_found } }
PREV = { states.remove_jurisdiction = yes }
}
else = { clr_country_flag = adm_center_found }
clr_country_flag = adm_center_in_state
}
else = { clr_country_flag = adm_center_found }
clr_country_flag = adm_center_in_state
}
}
clr_province_flag = state_prov_updated
}
}

Expand All @@ -41,7 +35,7 @@ states.update_all = {
# @access private
# @scope province
#
states.update_state = {
update_state = {

every_province_in_state = {

Expand All @@ -53,12 +47,6 @@ states.update_state = {
}
else_if = {
limit = { has_province_modifier = prov_state_adm_center }

# Calculate state administrative modifier for governance policy
owner = {
PREV = { states.get_development = yes }
states.get_dev_ratio = { DEV = output }
change_variable = { which = policy_gov_state_m which = output }
}

# Check to make sure every province in state is under jurisdiction
Expand All @@ -75,7 +63,7 @@ states.update_state = {
else_if = {
limit = {
has_admin_building = yes
can_build_courthouse = yes
can_build_adm_center = yes
}
states.apply_jurisdiction = yes
owner = { set_country_flag = adm_center_found }
Expand All @@ -88,8 +76,9 @@ states.update_state = {

# Update every province that does not belong to a state
# @scope country
# @access public
#
states.update_non_states = {
states.update_territories = {

every_owned_province = {
limit = { NOT = { is_state = yes } }
Expand Down Expand Up @@ -155,7 +144,6 @@ states.remove_jurisdiction = {
limit = { has_province_modifier = prov_state_adm_center }
remove_province_modifier = prov_state_adm_center
}

# Note that this will not remove modifiers if the provinces are not in state
# we will have to manually scan for these and remove them later on
#
Expand Down
2 changes: 1 addition & 1 deletion common/scripted_triggers/eve_scripted_triggers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ has_admin_building = {
}
}

can_build_courthouse = {
can_build_adm_center = {
is_state = yes
NOT = {
is_capital = yes
Expand Down
1 change: 0 additions & 1 deletion events/eve_event_flavor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ province_event = {

trigger = {
province.is_player_owned = yes
#has_building = courthouse
}

option = {
Expand Down

0 comments on commit 96e90f3

Please sign in to comment.