#load-if-not-defined VICTORY-CONQUEST

(defrule
	(goal personality 1)
	(not (goal wonder-attempt NO) )
=>
	(set-goal wonder-attempt NO)
)

(defrule
	(goal wonder-attempt MAYBE)
	(taunt-detected any-ally 200)
=>
	(set-goal wonder-attempt NO)
	(set-goal upgrade-conflict NO)
	(acknowledge-taunt this-any-ally 200)
	(disable-self)
)

;should we construct a wonder?
(defrule
	(goal wonder-attempt MAYBE)
	(current-age == imperial-age)
	(population > unit-max)
	(wood-amount >= 500)
	(gold-amount >= 500)
	(stone-amount >= 500)
	(cc-players-building-type-count every-ally wonder == 0)
	(cc-players-building-type-count every-enemy wonder == 0)
	(cc-players-building-type-count every-neutral wonder == 0)
	(not (goal personality 1) )
=>
	(set-goal upgrade-conflict NOTICE)
	(set-goal wonder-attempt POSSIBLE)
	(chat-to-player-using-id every-ally 22410)	;200
	(disable-timer t-ageup)
	(disable-self)
)

(defrule
	(goal wonder-attempt POSSIBLE)
=>
	(enable-timer t-ageup 1)
	(disable-self)
)

(defrule
	(timer-triggered t-ageup)
	(goal wonder-attempt POSSIBLE)
	(stone-amount < 1000)
=>
	(chat-to-player every-ally "6")
	(disable-timer t-ageup)
	(enable-timer t-ageup 150)
)

(defrule
	(timer-triggered t-ageup)
	(goal wonder-attempt POSSIBLE)
	(gold-amount < 1000)
=>
	(chat-to-player every-ally "5")
	(disable-timer t-ageup)
	(enable-timer t-ageup 150)
)

(defrule
	(timer-triggered t-ageup)
	(goal wonder-attempt POSSIBLE)
	(wood-amount < 1000)
=>
	(chat-to-player every-ally "4")
	(disable-timer t-ageup)
	(enable-timer t-ageup 150)
)

(defrule
	(goal wonder-attempt POSSIBLE)
	(can-build-with-escrow wonder)
=>
	(set-strategic-number sn-maximum-town-size 10)
	(set-strategic-number sn-percent-civilian-builders 90)
	(set-strategic-number sn-cap-civilian-builders 50)
	(set-strategic-number sn-percent-civilian-gatherers 10)
	(chat-local-to-self "Time to Wonder")
	(set-goal wonder-attempt YES)
	(disable-timer t-ageup)
	(enable-timer t-ageup 30)
	(disable-self)
)

(defrule
	(goal wonder-attempt YES)
	(building-type-count farm > 0)
=>
	(delete-building farm)
)

(defrule
	(goal wonder-attempt YES)
	(building-type-count farm == 0)
	(can-build-with-escrow wonder)
=>
	(release-escrow wood)
	(release-escrow gold)
	(release-escrow stone)
	(build wonder)
	(set-goal upgrade-conflict NO)
	(set-goal wonder-attempt NO)
	(disable-self)
)

(defrule
	(building-type-count-total wonder > 0)
=>
	(set-strategic-number sn-maximum-town-size imperial-town-size)
	(disable-self)
)

(defrule
	(building-type-count wonder > 0)
=>
	(set-strategic-number sn-percent-civilian-builders 15)
	(set-strategic-number sn-cap-civilian-builders 8)
	(set-strategic-number sn-percent-civilian-gatherers 85)
	(disable-self)
)

;***********************************
;wonder-bashing
;delete wonder if someone else has beaten us to the punch
(defrule
	(building-type-count wonder == 0)
	(building-type-count-total wonder > 0)
	(cc-players-building-type-count any-ally wonder > 0)
	(or
		(enemy-captured-relics)
		(or
			(cc-players-building-type-count any-enemy wonder > 0)
			(cc-players-building-type-count any-neutral wonder > 0)
		)
	)
=>
	(delete-building wonder)
	(set-strategic-number sn-maximum-town-size imperial-town-size)
	(set-strategic-number sn-percent-civilian-builders 15)
	(set-strategic-number sn-cap-civilian-builders 8)
	(set-strategic-number sn-percent-civilian-gatherers 85)
	(set-goal wonder-attempt NO)
	(set-goal upgrade-conflict NO)
	(disable-self)
)

#end-if



