uses paul/region-layout.df

map{ regiondef{

	: locid-bungalow make-bungalow ;
	: locid-gablehouse make-gable-house ;
	: locid-2storeyhouse make-2storey-house ;

	// Picks the more low-rent looking houses
	: make-a-house 
		10 %chance if
			locid-gablehouse
		else
			rnd5050 if locid-bungalow else locid-2storeyhouse then
		then grass-lotw walkway
	;

	: make-apartments ( locationid ) 
		road_theme@ case
			0 of make-florida-building endof
			1 of make-carolina-building endof
			otherwise prefab{ mrand 5 8 rnd 0 building }
		endcase paved-lotw 
	;
	
	: office-signs
		1 5 rnd case
			1 of "傻蛋 & 斯隆" endof
			2 of "铁法'律师所 " endof
			3 of "父 & 子" endof
			4 of "电子媒体股份有限公司" endof
			5 of "蓝牙在线" endof
		endcase
	;
	: restaurant-signs
		1 5 rnd case
			1 of "沸腾的马铃薯" endof
			2 of "意大利面特供" endof
			3 of "肉之宴" endof
			4 of "奔跑吧!咖喱" endof
			5 of "乡镇风光" endof
		endcase
	;
	
	: prefab-shop sign-text! prefab{ 0 3 rnd 9 0 shop } paved-lotw ;
	: prefab-shop2 sign-text! prefab{ 0 3 rnd 9 0 shop2 } paved-lotw ;
	: prefab-apt sign-text! prefab{ mrand 7 9 rnd 0 building } paved-lotw ;
	: prefab-house sign-text! prefab{ mrand 6 0 building2 } paved-lotw ;
	
	// Super rares
	
	: make-a-lab "推测科技" sign-text! prefab{ 0 3 rnd 10 0 shop } paved-lotw ;
	: make-a-raretest "只为测试你" sign-text! prefab{ 0 3 rnd 10 0 shop } paved-lotw ;
	: make-a-comic "尸之穴漫画" prefab-shop2 ;
	: make-a-animestore "漫画之家" prefab-shop2 ;
	: make-a-toilet "马桶天堂" prefab-shop2 ;
	
	// Special Lot Prefabs
	
	: make-a-pub "孟斯酒吧" prefab-shop ;
	: make-a-gunshop "枪*店" sign-text! prefab{ 1 3 rnd 9 0 shop } paved-lotw ;
	: make-a-foodshop "轻松食物坊" prefab-shop2 ;
	
	: make-a-jockshop "运动 & 汗水" prefab-shop2 ;
	: make-a-petshop "-宠物-之家-" prefab-shop2 ;
	: make-a-camping "野营者仓库" prefab-shop2 ;
	: make-a-hardware "厄尔林五金店" prefab-shop2 ;
	: make-a-umbrella "雨伞专供" prefab-shop2 ;
	: make-a-drugshop "格林药房" prefab-shop2 ;
	: make-a-sportshop "超级运动汇" prefab-shop2 ;
	: make-a-banner "这很安全!" prefab-house ;
	: make-a-infest "弗莱德堡垒 " prefab-house ;
	: make-a-barkapt "汪! 汪!" prefab-apt ;
	: make-a-rescueapt "救命" prefab-apt ;
	
	: make-a-bookshop "清美书店" sign-text! prefab{ 0 9 0 shop } paved-lotw ;
	: make-a-police "联邦警局" sign-text! prefab{ 5 9 0 shop } paved-lotw ;
	: make-a-clinic "轻-松-诊所" sign-text! prefab{ 4 9 0 shop } paved-lotw ;
	: make-a-office office-signs sign-text! prefab{ 0 1 rnd 9 0 shop } paved-lotw ;
	: make-a-gym 
		"动感! 爆裂!! 肌肉!!"
		0.5 0.5 0.5 sign-border!
		0.1 0.1 0.1 sign-bg!
		1 0.5 0.5 sign-fg!
		prefab-shop2
	;
	: make-a-coffee "启迪咖啡屋" sign-text! prefab{ 0 9 0 shop } paved-lotw ;
	: make-a-restaurant restaurant-signs prefab-shop ;
	: make-a-arcade "毁掉四分之一的电玩城" prefab-shop2 ;
	: make-a-furnshop "金典家居" prefab-shop2 ;
		
	: aplot add-a-path+ grass-lotw rnd5050 if 1 lot-back-fence+ then next-plot ;

	: block-last-build-door
		last-build-doorxy tile@ 0= if then;
		last-build-doorxy crap-aroundxy
		last-build-doorxy blocked
		2 for last-build-doorxy swap -3 3 rnd + swap 0 2 rnd + crap-aroundxy next
		last-build-doorxy 1+ crap-aroundxy
//		last-build-doorxy 1+ tile@ if -8 last-build-doorxy 1+ tile@ .offy! then
		last-build-doorxy 1+ tile@ if last-build-doorxy 1+ tile@ LAYER_WALLSIDE -4 4 rnd -8 .tile_layer.off! then
	;

// 0 make-apartments // EXAMPLE... apartments with no door!

	: trashed-house-maker
		dup if
			addloc last-loc-pick-script evaluate
		else drop
			"trashed" $picklocid addloc	make-a-house
			90 %chance if block-last-build-door then
		then
	;
	
	: trashed-apartment-maker
		dup if
			addloc last-loc-pick-script evaluate
		else drop
			"trashed" $picklocid addloc	make-apartments
			90 %chance if block-last-build-door then
		then
	;
	
	: trashed-maker 50 %chance if trashed-house-maker else trashed-apartment-maker then ;

(*	: pick-building ;
	: canplotter 
		begin canplot? while
			pick-building next-plot
			canplot? 0= if break then
			block-middle? if LOT_GRASS lastlot = if 1 else 0 then aplot then
		repeat
	;
*)
	
// places
		
	: houseorapt
		50 %chance if
		"
			loc-choice: house
			loc-weight: 40
			loc-count: 1

			loc-pick-script: make-a-house
		"
		else
		"
			loc-choice: apartments
			loc-weight: 30
			loc-count: 1
			loc-pick-script: make-apartments
		"
		then	
	;
	
	: houseorapt-trash
		50 %chance if
		"
			loc-choice: trash-h
			loc-weight: 40
			loc-count: 1

			loc-pick-script: make-a-house
		"
		else
		"
			loc-choice: trash-a
			loc-weight: 30
			loc-count: 1
			loc-pick-script: make-apartments
		"
		then	
	;

	: minilab
		"events/rareloc/minilab.df" $load
		"../deathforth/events/rareloc/labs.txt" $add-rooms
		"
			loc-choice: minilab
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-a-lab
		"
	;
	
	: gordon
		"events/rareloc/gordon.df" $load
		"
			loc-choice: gordon
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-apartments
		"
	;
	
	: heman
		"events/rareloc/heman.df" $load
		"
			loc-choice: heman
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-apartments
		"
	;
	
	: fairyqueen
		"events/rareloc/fairy.df" $load
		"
			loc-choice: fairy
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-apartments
		"
	;
	
	: panda
		"events/rareloc/panda.df" $load
		"
			loc-choice: panda
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-apartments
		"
	;
	
	: secretlab
		"events/rareloc/secretlab.df" $load
		"../deathforth/events/rareloc/labs.txt" $add-rooms
		"
			loc-choice: secretlab
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-a-house
		"
	;
	
	: secretbunker
		"events/rareloc/secretbunker.df" $load
		"
			loc-choice: secretbunker
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-a-house
		"
	;
	
	: apt-altar
		"events/rareloc/apt-altar.df" $load
		"
			loc-choice: apt-altar
			loc-weight: 40
			loc-count: 1
			loc-pick-script: make-apartments
		"
	;
	
	: disco
		"events/rareloc/disco-51.df" $load
		"
			loc-choice: disco51
			loc-weight: 40
			loc-count: 1
			loc-pick-script: disco-club
		"
	;
	
	: toiletheaven
		"events/rareloc/toiletheaven.df" $load
		"
			loc-choice: toiletheaven
			loc-weight: 30
			loc-count: 1
			loc-pick-script: make-a-toilet
		"
	;
	
	: comicbook
		"events/rareloc/comicstore.df" $load
		"
			loc-choice: comicstore
			loc-weight: 30
			loc-count: 1
			loc-pick-script: make-a-comic
		"
	;
	
	: animestore
		"events/rareloc/animestore.df" $load
		"
			loc-choice: animestore
			loc-weight: 30
			loc-count: 1
			loc-pick-script: make-a-animestore
		"
	; 

	
	: raretest
		"
			loc-choice: house
			loc-weight: 30
			loc-count: 1
			loc-pick-script: make-a-raretest
		"
	;

	deck-new
		
		// card: disco
		// (* 
		card: minilab
		card: comicbook
		card: animestore
		card: apt-altar
		card: secretlab
		card: secretbunker
		card: gordon
		card: fairyqueen
		card: panda
		card: heman
		card: toiletheaven 
		// *) card: animestore
		// card: raretest

	constant RARE-LOT-DECK
	RARE-LOT-DECK shuffles var rare-lot-deck

	: rarething
		// 10 default
		10 %chance if 
		// goodfx
		rare-lot-deck depths ( does not consume the deck ) 0= if
			drop ""
		else
			drawcard ( consumes the deck )
		then
		else
		""
		then
	;
	
	: easyregcity
		houseorapt evaluate
		houseorapt-trash evaluate
	;
	
	: regcity
		houseorapt evaluate
		houseorapt evaluate
		houseorapt-trash evaluate
		rarething evaluate
	;
	
} }

// Pass the location ID in to the following to create a new building
//		prefab{ mrand ( style ) 0 2 rnd 2 * 5 + ( width ) 0 ( depth ) theme-generic-building }
