diff --git a/twe/sammo/CityConst.php b/twe/sammo/CityConst.php new file mode 100644 index 00000000..8451240f --- /dev/null +++ b/twe/sammo/CityConst.php @@ -0,0 +1,343 @@ +1,1=>'하북', + '중원'=>2,2=>'중원', + '서북'=>3,3=>'서북', + '서촉'=>4,4=>'서촉', + '남중'=>5,5=>'남중', + '초'=>6,6=>'초', + '오월'=>7,7=>'오월', + '동이'=>8,8=>'동이' + ]; + + public static $levelMap = [ + '수'=>1,1=>'수', + '진'=>2,2=>'진', + '관'=>3,3=>'관', + '이'=>4,4=>'이', + '소'=>5,5=>'소', + '중'=>6,6=>'중', + '대'=>7,7=>'대', + '특'=>8,8=>'특' + ]; + + /** + * @return \sammo\CityInitialDetail[] + */ + public static function all(){ + static::_generate(); + return static::$constID; + } + public static function byID(int $id): CityInitialDetail{ + static::_generate(); + return static::$constID[$id]; + } + + public static function byName(string $name): CityInitialDetail{ + static::_generate(); + return static::$constName[$name]; + } + + public static function byRegion(int $region): CityInitialDetail{ + static::_generate(); + return static::$constRegion[$region]; + } + + private static $initCity = [ + //id, 도시, 규모, 인구, 농, 상, 치, 성, 수,(x100) 지역, 연결도시 + [ 1, '업', '특', 6205, 125, 113, 100, 117, 122, '하북', ['남피', '복양', '호관', '계교', '관도']], + [ 2, '허창', '특', 5876, 121, 124, 100, 117, 125, '중원', ['완', '진류', '초', '호로', '사수', '관도']], + [ 3, '낙양', '특', 8357, 117, 120, 100, 121, 124, '중원', ['호관', '호로', '사곡', '사수']], + [ 4, '장안', '특', 5923, 116, 123, 100, 120, 118, '서북', ['안정', '함곡', '기산']], + [ 5, '성도', '특', 6525, 123, 125, 100, 125, 123, '서촉', ['덕양', '강주', '면죽']], + [ 6, '양양', '특', 5837, 120, 126, 100, 115, 117, '초', ['신야', '장판']], + [ 7, '건업', '특', 6386, 116, 123, 100, 115, 119, '오월', ['오', '합비', '광릉']], + + [ 8, '북평', '대', 4862, 102, 95, 80, 103, 99, '하북', ['역경', '백랑']], + [ 9, '남피', '대', 5032, 99, 101, 80, 101, 105, '하북', ['업', '평원', '역경']], + [10, '완', '대', 4724, 103, 100, 80, 101, 99, '중원', ['허창', '여남', '신야', '호로']], + [11, '수춘', '대', 5143, 99, 96, 80, 99, 95, '중원', ['서주', '여남', '초', '합비']], + [12, '서주', '대', 4853, 101, 98, 80, 102, 97, '중원', ['수춘', '하비', '초', '패']], + [13, '강릉', '대', 4850, 105, 96, 80, 95, 96, '초', ['장사', '무릉', '이릉', '장판']], + [14, '장사', '대', 4710, 97, 99, 80, 100, 105, '초', ['강릉', '시상', '계양', '무릉', '영릉']], + [15, '시상', '대', 5252, 98, 100, 100, 99, 96, '오월', ['장사', '여강', '고창', '적벽', '파양']], + [16, '위례', '대', 4926, 100, 93, 80, 98, 103, '동이', ['평양', '사비', '계림', '안평', '동황']], + + [17, '계', '중', 3885, 75, 80, 60, 78, 81, '하북', ['진양', '역경']], + [18, '복양', '중', 4185, 80, 83, 60, 82, 80, '중원', ['업', '진류', '계교', '정도']], + [19, '진류', '중', 3957, 82, 80, 60, 80, 83, '중원', ['허창', '복양', '사수', '관도', '정도']], + [20, '여남', '중', 3831, 77, 81, 60, 84, 77, '중원', ['완', '수춘', '초']], + [21, '하비', '중', 4278, 85, 83, 60, 82, 78, '중원', ['서주', '광릉']], + [22, '서량', '중', 3874, 77, 79, 60, 83, 80, '서북', ['천수', '강', '저']], + [23, '하내', '중', 3736, 77, 81, 60, 81, 80, '서북', ['진양', '홍농', '흉노', '호관']], + [24, '한중', '중', 4027, 77, 84, 60, 80, 85, '서촉', ['상용', '양평', '기산']], + [25, '상용', '중', 3687, 78, 76, 60, 77, 81, '서촉', ['한중', '신야']], + [26, '덕양', '중', 3803, 81, 84, 60, 79, 77, '서촉', ['성도', '강주', '자동', '영안']], + [27, '강주', '중', 4126, 79, 80, 60, 84, 81, '서촉', ['성도', '덕양', '영안', '귀양', '주시']], + [28, '건녕', '중', 3765, 82, 80, 60, 86, 81, '남중', ['귀양', '운남', '남영']], + [29, '남해', '중', 3803, 82, 76, 60, 80, 81, '남중', ['교지', '상동', '대', '산월']], + [30, '계양', '중', 3955, 83, 80, 60, 81, 77, '초', ['장사', '영릉', '상동']], + [31, '오', '중', 4355, 77, 81, 60, 77, 76, '오월', ['건업', '회계', '파양', '탐라']], + [32, '평양', '중', 3982, 78, 80, 60, 83, 78, '동이', ['위례', '졸본']], + [33, '사비', '중', 4157, 77, 79, 60, 78, 80, '동이', ['위례', '계림', '탐라']], + [34, '계림', '중', 3911, 80, 74, 60, 81, 78, '동이', ['위례', '사비', '이도', '탐라']], + + [35, '진양', '소', 3074, 56, 59, 40, 64, 59, '하북', ['계', '하내', '호관']], + [36, '평원', '소', 3074, 62, 65, 40, 61, 63, '하북', ['남피', '북해', '계교']], + [37, '북해', '소', 3146, 55, 63, 40, 63, 58, '하북', ['평원', '패', '동황']], + [38, '초', '소', 3286, 60, 62, 40, 62, 57, '중원', ['허창', '수춘', '서주', '여남', '정도']], + [39, '패', '소', 2877, 64, 58, 40, 58, 59, '중원', ['서주', '북해', '정도']], + [40, '천수', '소', 2985, 59, 64, 40, 60, 58, '서북', ['서량', '안정', '저', '적도']], + [41, '안정', '소', 2764, 57, 59, 40, 57, 62, '서북', ['장안', '천수', '가정']], + [42, '홍농', '소', 2748, 57, 63, 40, 58, 63, '서북', ['하내', '사곡', '함곡']], + [43, '하변', '소', 2785, 58, 62, 40, 60, 56, '서촉', ['가맹', '가정']], + [44, '자동', '소', 2870, 57, 55, 40, 60, 58, '서촉', ['덕양', '양평', '가맹', '면죽']], + [45, '영안', '소', 3153, 62, 59, 40, 58, 59, '서촉', ['덕양', '강주', '이릉']], + [46, '귀양', '소', 2746, 58, 61, 40, 61, 58, '남중', ['강주', '건녕', '주시']], + [47, '주시', '소', 2828, 60, 59, 40, 58, 63, '남중', ['강주', '귀양', '운남']], + [48, '운남', '소', 3258, 62, 60, 40, 64, 61, '남중', ['건녕', '주시', '남만']], + [49, '남영', '소', 2853, 59, 62, 40, 58, 57, '남중', ['건녕', '영릉', '남만']], + [50, '교지', '소', 3195, 58, 59, 40, 58, 59, '남중', ['남해', '남만']], + [51, '신야', '소', 2786, 60, 62, 40, 58, 55, '초', ['양양', '완', '상용']], + [52, '강하', '소', 3074, 55, 56, 40, 57, 60, '초', ['장판', '적벽']], + [53, '무릉', '소', 3196, 58, 63, 40, 63, 58, '초', ['강릉', '장사', '영릉']], + [54, '영릉', '소', 2849, 62, 58, 40, 62, 62, '초', ['장사', '계양', '남영', '무릉']], + [55, '상동', '소', 2767, 58, 59, 40, 62, 58, '초', ['남해', '계양', '고창']], + [56, '여강', '소', 2905, 56, 58, 40, 60, 55, '오월', ['시상', '합비', '적벽', '파양']], + [57, '회계', '소', 3005, 64, 59, 40, 62, 64, '오월', ['오', '산월']], + [58, '고창', '소', 2802, 57, 62, 40, 58, 63, '오월', ['시상', '상동', '산월']], + [59, '대', '소', 3256, 60, 62, 40, 57, 60, '오월', ['남해', '산월', '유구']], + [60, '안평', '소', 2937, 63, 59, 40, 59, 63, '동이', ['위례', '졸본', '동황', '백랑']], + [61, '졸본', '소', 2939, 55, 59, 40, 60, 58, '동이', ['평양', '안평', '오환']], + [62, '이도', '소', 3174, 58, 61, 40, 58, 56, '동이', ['계림', '왜', '탐라']], + + [63, '강', '이', 2095, 40, 42, 20, 43, 40, '서북', ['서량', '적도']], + [64, '저', '이', 1957, 40, 42, 20, 43, 42, '서북', ['서량', '천수', '가정']], + [65, '흉노', '이', 2064, 40, 41, 20, 40, 38, '서북', ['하내', '적도']], + [66, '남만', '이', 2378, 40, 42, 20, 43, 45, '남중', ['운남', '남영', '교지']], + [67, '산월', '이', 2275, 40, 37, 20, 43, 38, '오월', ['남해', '회계', '고창', '대']], + [68, '오환', '이', 2153, 42, 37, 20, 43, 40, '동이', ['졸본', '백랑']], + [69, '왜', '이', 2065, 39, 37, 20, 43, 41, '동이', ['이도', '유구']], + + [70, '호관', '관', 887, 19, 18, 20, 95, 96, '하북', ['업', '낙양', '하내', '진양']], + [71, '호로', '관', 1112, 22, 21, 20, 103, 98, '중원', ['허창', '낙양', '완']], + [72, '사곡', '관', 1008, 21, 19, 20, 99, 101, '서북', ['낙양', '홍농']], + [73, '함곡', '관', 1081, 20, 22, 20, 101, 102, '서북', ['장안', '홍농']], + [74, '사수', '관', 958, 17, 19, 20, 95, 96, '중원', ['허창', '낙양', '진류', '관도']], + [75, '양평', '관', 868, 19, 19, 20, 97, 96, '서촉', ['한중', '자동', '기산']], + [76, '가맹', '관', 855, 17, 18, 20, 96, 95, '서촉', ['하변', '자동']], + + [77, '역경', '진', 985, 18, 19, 20, 39, 41, '하북', ['북평', '남피', '계']], + [78, '계교', '진', 1012, 21, 19, 20, 40, 42, '하북', ['업', '복양', '평원']], + [79, '동황', '진', 992, 19, 21, 20, 38, 40, '하북', ['위례', '북해', '안평']], + [80, '관도', '진', 1123, 22, 20, 20, 42, 43, '중원', ['업', '허창', '진류', '사수']], + [81, '정도', '진', 1085, 21, 21, 20, 41, 38, '중원', ['복양', '진류', '초', '패']], + [82, '합비', '진', 998, 20, 19, 20, 39, 41, '중원', ['건업', '수춘', '여강']], + [83, '광릉', '진', 1001, 20, 21, 20, 41, 40, '중원', ['건업', '하비']], + [84, '적도', '진', 952, 18, 17, 20, 38, 37, '서북', ['천수', '강', '흉노']], + [85, '가정', '진', 931, 17, 17, 20, 36, 38, '서북', ['안정', '하변', '저']], + [86, '기산', '진', 1005, 19, 18, 20, 41, 40, '서촉', ['장안', '한중', '양평']], + [87, '면죽', '관', 1093, 22, 21, 20, 108, 99, '서촉', ['성도', '자동']], + [88, '이릉', '진', 968, 18, 19, 20, 39, 41, '초', ['강릉', '영안']], + [89, '장판', '진', 1032, 21, 20, 20, 40, 37, '초', ['양양', '강릉', '강하', '적벽']], + [90, '백랑', '진', 1052, 22, 19, 20, 38, 42, '동이', ['북평', '안평', '오환']], + + [91, '적벽', '수', 1117, 23, 21, 20, 42, 41, '오월', ['시상', '강하', '여강', '장판']], + [92, '파양', '수', 1037, 20, 22, 20, 38, 38, '오월', ['시상', '오', '여강']], + [93, '탐라', '수', 1130, 22, 21, 20, 43, 41, '동이', ['오', '사비', '계림', '이도']], + [94, '유구', '수', 921, 17, 18, 20, 37, 37, '동이', ['대', '왜']], + ]; + + private static function _generate(){ + if(static::$constID || static::$constName || static::$constCity || static::$constRegion){ + return; + } + + $constID = []; + $constName = []; + $constCity = []; + $constRegion = []; + + $nameMap = []; + + foreach (static::$initCity as $rawCity) { + $nameMap[$rawCity[1]] = $rawCity[0]; + } + + foreach (static::$buildInit as $key=>$val){ + $key2 = static::$levelMap[$key]; + if(key_exists($key2, static::$buildInit)){ + continue;//혹시 모를 버그 방지 + } + + static::$buildInit[$key2] = $val; + } + + foreach(static::$initCity as $rawCity){ + list( + $id, + $name, + $level, + $population, + $agriculture, + $commerce, + $security, + $defence, + $wall, + $region, + $path + ) = $rawCity; + + $level = static::$levelMap[$level]; + $population *= 100; + $agriculture *= 100; + $commerce *= 100; + $security *= 100; + $defence *= 100; + $wall *= 100; + $region = static::$regionMap[$region]; + $newPath = []; + foreach($path as $pathName){ + $pathID = $nameMap[$pathName]; + $newPath[$pathID] = $pathName; + } + + $city = new CityInitialDetail( + $id, + $name, + $level, + $population, + $agriculture, + $commerce, + $security, + $defence, + $wall, + $region, + $newPath + ); + + $constID[$id] = $city; + $constName[$name] = $city; + if(!key_exists($region, $constRegion)){ + $constRegion[$region] = []; + } + $constRegion[$region] = $city; + } + + static::$constID = $constID; + static::$constName = $constName; + static::$constRegion = $constRegion; + + } + + private static $buildInitCommon = [ + 'rate'=>50, + 'trade'=>100, + 'gen1'=>0, + 'gen2'=>0, + 'gen3'=>0 + ]; + + private static $buildInit = [ + '수'=>[ + 'pop' => 5000, + 'agri'=> 100, + 'comm'=> 100, + 'secu'=> 100, + 'def' => 500, + 'wall'=> 500, + ], + '진'=>[ + 'pop' => 5000, + 'agri'=> 100, + 'comm'=> 100, + 'secu'=> 100, + 'def' => 500, + 'wall'=> 500, + ], + '관'=>[ + 'pop' => 10000, + 'agri'=> 100, + 'comm'=> 100, + 'secu'=> 100, + 'def' => 1000, + 'wall'=> 1000, + ], + '이'=>[ + 'pop' => 50000, + 'agri'=> 1000, + 'comm'=> 1000, + 'secu'=> 1000, + 'def' => 1000, + 'wall'=> 1000, + ], + '소'=>[ + 'pop' =>100000, + 'agri'=> 1000, + 'comm'=> 1000, + 'secu'=> 1000, + 'def' => 2000, + 'wall'=> 2000, + ], + '중'=>[ + 'pop' =>100000, + 'agri'=> 1000, + 'comm'=> 1000, + 'secu'=> 1000, + 'def' => 3000, + 'wall'=> 3000, + ], + '대'=>[ + 'pop' =>150000, + 'agri'=> 1000, + 'comm'=> 1000, + 'secu'=> 1000, + 'def' => 4000, + 'wall'=> 4000, + ], + '특'=>[ + 'pop' =>150000, + 'agri'=> 1000, + 'comm'=> 1000, + 'secu'=> 1000, + 'def' => 5000, + 'wall'=> 5000, + ] + ]; + + public static function build(){ + static::_generate(); + + $queries = array_map(function(CityInitialDetail $city){ + $initValue = static::$buildInit[$city->level]; + $path = join('|', array_keys($city->path)); + return array_merge(static::$buildInitCommon, $initValue, [ + 'city'=>$city->id, + 'name'=>$city->name, + 'level'=>$city->level, + 'path'=>$path, + 'pop2'=>$city->population, + 'agri2'=>$city->agriculture, + 'comm2'=>$city->commerce, + 'secu2'=>$city->security, + 'def2'=>$city->defence, + 'wall2'=>$city->wall, + 'region'=>$city->region + ]); + }, static::$constID); + + DB::db()->insert('city', $queries); + } +} diff --git a/twe/sammo/CityInitialDetail.php b/twe/sammo/CityInitialDetail.php new file mode 100644 index 00000000..fd9df423 --- /dev/null +++ b/twe/sammo/CityInitialDetail.php @@ -0,0 +1,43 @@ +id = $id; + $this->name = $name; + $this->level = $level; + $this->population = $population; + $this->agriculture = $agriculture; + $this->commerce = $commerce; + $this->security = $security; + $this->defence = $defence; + $this->wall = $wall; + $this->region = $region; + $this->path = $path; + } + +} \ No newline at end of file diff --git a/twe/sammo/GameUnitConst.php b/twe/sammo/GameUnitConst.php new file mode 100644 index 00000000..07e6a760 --- /dev/null +++ b/twe/sammo/GameUnitConst.php @@ -0,0 +1,144 @@ +name = $name; + $this->attack = $attack; + $this->defence = $defence; + $this->speed = $speed; + $this->avoid = $avoid; + $this->cost = $cost; + $this->rice = $rice; + $this->recruitType = $recruitType; + $this->recruitPlace = $recruitPlace; + $this->recruitFirst = $recruitFirst; + } +} \ No newline at end of file