0) { RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1492, 123, "가화",$img,1492, 0, "-", 50, 66, 40, 0, 176, 224, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1493, 999, "건석",$img,1493, 0, "-", 21, 12, 61, 0, 155, 189, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1494, 999, "견씨",$img,1494, 0, "-", 35, 24, 58, 0, 182, 221, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1495, 40, "견홍",$img,1495, 0, "-", 76, 72, 66, 0, 224, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1496, 120, "고담",$img,1496, 0, "-", 33, 21, 69, 0, 203, 244, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1497, 101, "고유",$img,1497, 0, "-", 56, 44, 73, 0, 174, 263, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1498, 132, "곽마",$img,1498, 0, "-", 68, 71, 49, 0, 239, 280, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1499, 39, "관구수",$img,1499, 0, "-", 58, 63, 35, 0, 206, 265, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1500, 39, "관구전",$img,1500, 0, "-", 63, 58, 68, 0, 224, 255, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1501, 999, "관로",$img,1501, 0, "-", 62, 21, 75, 0, 191, 256, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1502, 65, "관정",$img,1502, 0, "-", 35, 50, 73, 0, 158, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1503, 137, "교수",$img,1503, 0, "-", 67, 69, 39, 0, 143, 195, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1504, 33, "구건",$img,1504, 0, "-", 43, 56, 69, 0, 239, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1505, 41, "구본",$img,1505, 0, "-", 52, 41, 70, 0, 232, 269, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1506, 12, "구성",$img,1506, 0, "-", 56, 71, 31, 0, 157, 187, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1507, 21, "국연",$img,1507, 0, "-", 52, 21, 71, 0, 160, 219, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1508, 99, "국의",$img,1508, 0, "-", 83, 79, 50, 0, 146, 191, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1509, 34, "금의",$img,1509, 0, "-", 18, 40, 63, 0, 177, 218, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1510, 76, "나헌",$img,1510, 0, "-", 86, 67, 75, 0, 218, 270, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1511, 999, "남두",$img,1511, 0, "-", 35, 25, 54, 0, 130, 200, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1512, 54, "냉포",$img,1512, 0, "-", 70, 82, 69, 0, 176, 214, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1513, 124, "노숙2",$img,1513, 0, "-", 70, 55, 76, 0, 208, 274, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1514, 42, "누규",$img,1514, 0, "-", 54, 19, 88, 0, 143, 212, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1515, 6, "누반",$img,1515, 0, "-", 65, 76, 39, 0, 178, 207, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1516, 130, "누현",$img,1516, 0, "-", 23, 20, 68, 0, 223, 275, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1517, 40, "당균",$img,1517, 0, "-", 33, 19, 81, 0, 229, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1518, 32, "당빈",$img,1518, 0, "-", 70, 74, 62, 0, 235, 294, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1519, 999, "대교",$img,1519, 0, "-", 42, 10, 54, 0, 177, 235, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1520, 28, "대릉",$img,1520, 0, "-", 64, 75, 45, 0, 199, 258, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1521, 129, "동조",$img,1521, 0, "-", 16, 15, 51, 0, 221, 281, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1522, 114, "등수",$img,1522, 0, "-", 35, 20, 44, 0, 228, 288, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1523, 50, "마막",$img,1523, 0, "-", 22, 17, 5, 0, 221, 265, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1524, 116, "만욱",$img,1524, 0, "-", 20, 18, 66, 0, 240, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1525, 120, "맹종",$img,1525, 0, "-", 48, 48, 67, 0, 216, 271, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1526, 38, "문호",$img,1526, 0, "-", 65, 74, 45, 0, 227, 279, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1527, 999, "미씨",$img,1527, 0, "-", 59, 15, 68, 0, 176, 208, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1528, 39, "반림",$img,1528, 0, "-", 66, 79, 8, 0, 168, 225, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1529, 129, "반장",$img,1529, 0, "-", 77, 78, 69, 0, 177, 222, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1530, 94, "방열",$img,1530, 0, "-", 58, 82, 28, 0, 153, 190, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1531, 55, "방희",$img,1531, 0, "-", 59, 38, 69, 0, 153, 218, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1532, 30, "배수",$img,1532, 0, "-", 10, 11, 77, 0, 223, 271, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1533, 8, "번능",$img,1533, 0, "-", 70, 61, 47, 0, 158, 194, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1534, 999, "번씨",$img,1534, 0, "-", 32, 17, 45, 0, 176, 220, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1535, 49, "보도근",$img,1535, 0, "-", 64, 73, 50, 0, 170, 233, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1536, 129, "보천",$img,1536, 0, "-", 68, 60, 72, 0, 222, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1537, 121, "보협",$img,1537, 0, "-", 73, 53, 75, 0, 216, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1538, 28, "부하",$img,1538, 0, "-", 44, 36, 85, 0, 209, 255, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1539, 26, "비요",$img,1539, 0, "-", 70, 65, 73, 0, 192, 228, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1540, 31, "사마주",$img,1540, 0, "-", 63, 53, 62, 0, 227, 283, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1541, 41, "사찬",$img,1541, 0, "-", 61, 71, 54, 0, 215, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1542, 128, "설후",$img,1542, 0, "-", 16, 14, 71, 0, 221, 271, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1543, 36, "성공영",$img,1543, 0, "-", 73, 58, 80, 0, 172, 220, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1544, 126, "성만",$img,1544, 0, "-", 61, 69, 66, 0, 225, 276, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1545, 999, "소교",$img,1545, 0, "-", 57, 23, 66, 0, 178, 218, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1546, 46, "소유",$img,1546, 0, "-", 51, 61, 48, 0, 164, 210, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1547, 31, "소제2",$img,1547, 0, "-", 22, 16, 78, 0, 224, 268, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1548, 126, "손교",$img,1548, 0, "-", 77, 60, 69, 0, 181, 219, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1549, 116, "손기",$img,1549, 0, "-", 62, 65, 52, 0, 227, 276, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1550, 999, "손상향",$img,1550, 0, "-", 72, 62, 42, 0, 193, 244, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1551, 125, "손익",$img,1551, 0, "-", 69, 75, 26, 0, 184, 204, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1552, 125, "손진",$img,1552, 0, "-", 64, 71, 48, 0, 234, 280, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1553, 123, "송겸",$img,1553, 0, "-", 61, 48, 44, 0, 175, 215, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1554, 85, "순심",$img,1554, 0, "-", 20, 21, 79, 0, 164, 208, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1555, 31, "순욱2",$img,1555, 0, "-", 10, 16, 77, 0, 225, 289, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1556, 31, "순의",$img,1556, 0, "-", 16, 11, 73, 0, 207, 281, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1557, 129, "시삭",$img,1557, 0, "-", 36, 66, 44, 0, 226, 268, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1558, 29, "신창",$img,1558, 0, "-", 51, 29, 46, 0, 210, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1559, 999, "악신",$img,1559, 0, "-", 53, 12, 46, 0, 175, 228, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1560, 138, "악취",$img,1560, 0, "-", 56, 68, 58, 0, 157, 195, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1561, 138, "양강",$img,1561, 0, "-", 62, 70, 42, 0, 160, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1562, 21, "양부",$img,1562, 0, "-", 68, 55, 85, 0, 178, 239, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1563, 72, "양서",$img,1563, 0, "-", 56, 62, 66, 0, 198, 260, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1564, 34, "양습",$img,1564, 0, "-", 67, 49, 73, 0, 168, 230, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1565, 16, "양앙",$img,1565, 0, "-", 65, 70, 39, 0, 172, 215, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1566, 17, "양임",$img,1566, 0, "-", 71, 78, 56, 0, 170, 215, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1567, 32, "양제",$img,1567, 0, "-", 69, 63, 71, 0, 226, 291, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1568, 33, "양조2",$img,1568, 0, "-", 65, 61, 67, 0, 223, 286, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1569, 48, "양추2",$img,1569, 0, "-", 66, 67, 61, 0, 172, 238, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1570, 140, "양홍",$img,1570, 0, "-", 19, 17, 76, 0, 152, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1571, 31, "양혼",$img,1571, 0, "-", 60, 67, 63, 0, 220, 278, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1572, 123, "여거",$img,1572, 0, "-", 71, 58, 69, 0, 196, 256, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1573, 130, "여대",$img,1573, 0, "-", 83, 72, 70, 0, 161, 256, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1574, 136, "염상",$img,1574, 0, "-", 29, 27, 69, 0, 158, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1575, 36, "염행",$img,1575, 0, "-", 70, 86, 38, 0, 159, 222, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1576, 73, "영수",$img,1576, 0, "-", 69, 70, 74, 0, 234, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1577, 39, "오거",$img,1577, 0, "-", 49, 63, 32, 0, 151, 211, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1578, 126, "오경",$img,1578, 0, "-", 73, 60, 57, 0, 159, 203, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1579, 999, "오국태",$img,1579, 0, "-", 31, 11, 60, 0, 161, 222, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1580, 126, "오찬",$img,1580, 0, "-", 69, 41, 78, 0, 181, 245, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1581, 23, "온회",$img,1581, 0, "-", 42, 40, 78, 0, 178, 222, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1582, 21, "왕기2",$img,1582, 0, "-", 70, 66, 63, 0, 217, 281, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1583, 32, "왕도",$img,1583, 0, "-", 48, 44, 70, 0, 210, 269, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1584, 123, "왕돈",$img,1584, 0, "-", 60, 65, 41, 0, 198, 256, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1585, 34, "왕릉",$img,1585, 0, "-", 73, 60, 71, 0, 172, 251, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1586, 63, "왕문",$img,1586, 0, "-", 64, 67, 32, 0, 162, 205, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1587, 32, "왕상",$img,1587, 0, "-", 25, 19, 65, 0, 180, 268, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1588, 34, "왕숙",$img,1588, 0, "-", 35, 21, 80, 0, 195, 256, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1589, 33, "왕업",$img,1589, 0, "-", 32, 6, 46, 0, 220, 280, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1590, 35, "왕충",$img,1590, 0, "-", 42, 58, 21, 0, 152, 214, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1591, 1, "우보",$img,1591, 0, "-", 43, 63, 12, 0, 159, 192, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1592, 122, "우사",$img,1592, 0, "-", 70, 33, 79, 0, 217, 273, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1593, 138, "원요",$img,1593, 0, "-", 44, 42, 45, 0, 177, 206, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1594, 95, "원유",$img,1594, 0, "-", 57, 38, 73, 0, 150, 193, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1595, 31, "위관",$img,1595, 0, "-", 69, 45, 81, 0, 220, 291, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1596, 129, "위막",$img,1596, 0, "-", 58, 62, 60, 0, 221, 268, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1597, 55, "유괴",$img,1597, 0, "-", 75, 72, 66, 0, 165, 214, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1598, 129, "유략",$img,1598, 0, "-", 72, 68, 59, 0, 206, 260, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1599, 45, "유반",$img,1599, 0, "-", 74, 79, 48, 0, 168, 210, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1600, 29, "유복",$img,1600, 0, "-", 54, 50, 73, 0, 164, 208, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1601, 78, "유선2",$img,1601, 0, "-", 9, 21, 39, 0, 224, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1602, 139, "유섭",$img,1602, 0, "-", 62, 79, 26, 0, 158, 190, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1603, 28, "유소",$img,1603, 0, "-", 66, 51, 73, 0, 195, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1604, 128, "유승",$img,1604, 0, "-", 46, 69, 29, 0, 215, 258, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1605, 129, "유찬",$img,1605, 0, "-", 74, 75, 66, 0, 172, 255, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1606, 129, "유평",$img,1606, 0, "-", 65, 70, 67, 0, 218, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1607, 138, "유훈",$img,1607, 0, "-", 51, 64, 50, 0, 163, 216, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1608, 48, "이감",$img,1608, 0, "-", 59, 67, 33, 0, 176, 211, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1609, 19, "이승",$img,1609, 0, "-", 13, 26, 32, 0, 201, 249, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1610, 22, "이통",$img,1610, 0, "-", 75, 84, 52, 0, 168, 211, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1611, 138, "이풍2",$img,1611, 0, "-", 72, 77, 50, 0, 158, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1612, 20, "이풍3",$img,1612, 0, "-", 23, 25, 71, 0, 204, 254, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1613, 29, "장구",$img,1613, 0, "-", 69, 71, 47, 0, 201, 263, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1614, 21, "장기",$img,1614, 0, "-", 77, 35, 79, 0, 170, 223, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1615, 74, "장남",$img,1615, 0, "-", 71, 64, 38, 0, 187, 222, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1616, 100, "장막",$img,1616, 0, "-", 53, 52, 70, 0, 155, 195, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1617, 7, "장만성",$img,1617, 0, "-", 73, 83, 47, 0, 143, 184, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1618, 135, "장반",$img,1618, 0, "-", 56, 73, 66, 0, 227, 282, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1619, 78, "장빈",$img,1619, 0, "-", 30, 28, 67, 0, 216, 263, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1620, 124, "장승",$img,1620, 0, "-", 75, 68, 75, 0, 178, 244, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1621, 999, "장양2",$img,1621, 0, "-", 58, 50, 47, 0, 130, 184, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1622, 68, "장억",$img,1622, 0, "-", 82, 80, 54, 0, 190, 254, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1623, 75, "장준",$img,1623, 0, "-", 65, 67, 66, 0, 224, 263, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1624, 20, "장집",$img,1624, 0, "-", 31, 27, 74, 0, 196, 254, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1625, 39, "장특",$img,1625, 0, "-", 71, 53, 74, 0, 209, 265, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1626, 96, "저곡",$img,1626, 0, "-", 57, 53, 67, 0, 184, 204, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1627, 128, "전기",$img,1627, 0, "-", 51, 69, 55, 0, 231, 258, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1628, 23, "전만",$img,1628, 0, "-", 52, 74, 38, 0, 181, 235, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1629, 128, "전상",$img,1629, 0, "-", 5, 6, 11, 0, 208, 258, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1630, 130, "전역",$img,1630, 0, "-", 60, 62, 37, 0, 212, 265, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1631, 75, "전예",$img,1631, 0, "-", 80, 62, 83, 0, 171, 252, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1632, 64, "전해",$img,1632, 0, "-", 71, 63, 57, 0, 154, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1633, 123, "정봉2",$img,1633, 0, "-", 67, 68, 52, 0, 198, 266, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1634, 22, "정의",$img,1634, 0, "-", 17, 3, 66, 0, 184, 220, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1635, 81, "제갈교",$img,1635, 0, "-", 55, 17, 77, 0, 204, 228, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1636, 40, "제갈서",$img,1636, 0, "-", 45, 43, 27, 0, 218, 286, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1637, 25, "조충",$img,1637, 0, "-", 14, 7, 80, 0, 196, 208, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1638, 121, "종리목",$img,1638, 0, "-", 84, 68, 75, 0, 214, 269, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1639, 22, "종육",$img,1639, 0, "-", 27, 11, 71, 0, 223, 263, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1640, 122, "좌혁",$img,1640, 0, "-", 60, 66, 51, 0, 232, 280, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1641, 36, "주령",$img,1641, 0, "-", 77, 70, 69, 0, 170, 236, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1642, 115, "주앙",$img,1642, 0, "-", 75, 64, 64, 0, 162, 195, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1643, 52, "주포",$img,1643, 0, "-", 59, 72, 12, 0, 191, 225, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1644, 11, "주흔",$img,1644, 0, "-", 67, 53, 77, 0, 159, 196, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1645, 140, "진기",$img,1645, 0, "-", 58, 67, 46, 0, 165, 198, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1646, 142, "진란",$img,1646, 0, "-", 65, 70, 43, 0, 157, 204, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1647, 25, "진랑",$img,1647, 0, "-", 57, 70, 38, 0, 192, 234, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1648, 12, "진응",$img,1648, 0, "-", 62, 69, 49, 0, 172, 208, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1649, 124, "진표",$img,1649, 0, "-", 62, 49, 74, 0, 204, 237, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1650, 999, "채염",$img,1650, 0, "-", 40, 22, 64, 0, 168, 237, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1651, 999, "초선",$img,1651, 0, "-", 66, 15, 72, 0, 176, 211, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1652, 135, "초이",$img,1652, 0, "-", 54, 65, 55, 0, 219, 266, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1653, 65, "추단",$img,1653, 0, "-", 63, 71, 36, 0, 148, 193, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1654, 999, "추씨",$img,1654, 0, "-", 36, 13, 54, 0, 165, 225, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1655, 71, "추정",$img,1655, 0, "-", 67, 65, 66, 0, 144, 193, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1656, 145, "파재",$img,1656, 0, "-", 69, 75, 52, 0, 145, 184, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1657, 22, "포신",$img,1657, 0, "-", 78, 60, 83, 0, 152, 192, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1658, 114, "하식",$img,1658, 0, "-", 18, 38, 29, 0, 230, 284, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1659, 36, "하안",$img,1659, 0, "-", 6, 27, 72, 0, 190, 249, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1660, 999, "하후씨",$img,1660, 0, "-", 29, 16, 47, 0, 186, 249, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1661, 5, "학맹",$img,1661, 0, "-", 57, 66, 41, 0, 156, 197, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1662, 98, "한거자",$img,1662, 0, "-", 53, 59, 30, 0, 158, 200, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1663, 19, "한덕",$img,1663, 0, "-", 62, 79, 24, 0, 171, 228, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1664, 140, "한윤",$img,1664, 0, "-", 27, 24, 68, 0, 155, 197, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1665, 999, "허소",$img,1665, 0, "-", 53, 27, 60, 0, 150, 195, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1666, 30, "호열",$img,1666, 0, "-", 77, 69, 76, 0, 225, 272, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1667, 76, "호제",$img,1667, 0, "-", 58, 42, 68, 0, 207, 264, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1668, 149, "호진",$img,1668, 0, "-", 65, 77, 13, 0, 146, 190, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1669, 29, "호질",$img,1669, 0, "-", 73, 50, 75, 0, 192, 250, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1670, 7, "환계",$img,1670, 0, "-", 12, 25, 67, 0, 156, 221, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1671, 56, "황숭",$img,1671, 0, "-", 68, 64, 74, 0, 208, 263, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1672, 999, "황승언",$img,1672, 0, "-", 68, 17, 81, 0, 165, 222, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1673, 999, "황월영",$img,1673, 0, "-", 58, 14, 75, 0, 186, 235, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1674, 45, "황조",$img,1674, 0, "-", 74, 65, 57, 0, 148, 208, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1675, 48, "후선",$img,1675, 0, "-", 56, 66, 35, 0, 175, 228, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1676, 8, "휴고",$img,1676, 0, "-", 61, 72, 40, 0, 151, 199, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1677, 98, "휴원진",$img,1677, 0, "-", 53, 63, 38, 0, 155, 200, "-", "-"); RegGeneral($connect,0,0,$fiction,$turnterm,$startyear,$year,1678, 22, "희지재",$img,1678, 0, "-", 24, 5, 86, 0, 157, 194, "-", "-"); } } function RegGeneral($connect,$init,$life,$fiction,$turnterm,$startyear,$year,$gencount,$npcmatch,$name,$img,$picture,$nation, $city,$leader,$power,$intel,$level, $bornyear,$deadyear,$personal,$special, $msg="") { $name = "ⓝ".$name; $npc = 2; if($city == "-") { $city = rand() % 94 + 1; } else { $city = CityCall($city); } if($npcmatch == 0 || $fiction == 1) { $npcmatch = rand() % 150 + 1; } if($life == 1) { $bornyear = 160; $deadyear = 300; } if($init != 0 && $startyear > $bornyear+14 && $startyear <= $deadyear) { if($deadyear <= $startyear+3) $deadyear += 5; $genid = "gen{$gencount}"; $turntime = getRandTurn($turnterm); if($personal != "-") { $personal = CharCall($personal); } else { $personal = rand() % 10; } if($fiction == 1) { $special = SpecCall("-"); } else { $special = SpecCall($special); } if($special >= 40) { $special2 = $special; $special = 0; } else { $special2 = 0; } if($picture == 0) { $picture = 1001 + rand() % 400; } if($picture == -1) { $picture = 'default'; } $picture = "{$picture}.jpg"; if($img < 3) { $picture = 'default.jpg'; } $age = $startyear - $bornyear; $specage = $age + 1; $specage2 = $age + 1; $killturn = ($deadyear - $startyear) * 12 + (rand() % 12); $experience = $age * 100; $dedication = $age * 100; if($nation != 0 && $level == 0) $level = 1; $pw = md5("18071807"); //장수 @MYDB_query(" insert into general ( npcid,npc,npc_org,npcmatch,user_id,password,name,picture,nation,city,leader,power,intel, experience,dedication,level,gold,rice,crew,crewtype,train,atmos, weap,book,horse,turntime,killturn,age,belong,personal,special,specage,special2,specage2,npcmsg, makelimit,bornyear,deadyear ) values ( '$gencount','$npc','$npc','$npcmatch','$genid','$pw','$name','$picture','$nation', '$city','$leader','$power','$intel','$experience','$dedication', '$level','1000','1000','0','0','0','0', '0','0','0','$turntime','$killturn','$age','1', '$personal','$special','$specage','$special2','$specage2','$msg', '0','$bornyear','$deadyear' )", $connect ) or Error(__LINE__.MYDB_error($connect),""); } elseif($year == $bornyear+14 && $year < $deadyear) { $genid = "gen{$gencount}"; $query = "select no from general where npcid='$gencount'"; $result = MYDB_query($query, $connect) or Error("func_npc ".MYDB_error($connect),""); $count = MYDB_num_rows($result); if($count == 0) { $turntime = getRandTurn($turnterm); if($personal != "-") { $personal = CharCall($personal); } else { $personal = rand() % 10; } if($fiction == 1) { $special = SpecCall("-"); } else { $special = SpecCall($special); } if($special >= 40) { $special2 = $special; $special = 0; } else { $special2 = 0; } if($picture == 0) { $picture = 1001 + rand() % 400; } $picture = "{$picture}.jpg"; if($img < 3) { $picture = 'default.jpg'; } $age = $year - $bornyear; $specage = $age + 1; $specage2 = $age + 1; $killturn = ($deadyear - $year) * 12 + (rand() % 12); $experience = $age * 100; $dedication = $age * 100; $pw = md5("18071807"); //장수 @MYDB_query(" insert into general ( npcid,npc,npc_org,npcmatch,user_id,password,name,picture,nation,city,leader,power,intel, experience,dedication,level,gold,rice,crew,crewtype,train,atmos, weap,book,horse,turntime,killturn,age,belong,personal,special,specage,special2,specage2,npcmsg, makelimit,bornyear,deadyear ) values ( '$gencount','$npc','$npc','$npcmatch','$genid','$pw','$name','$picture','0', '$city','$leader','$power','$intel','$experience','$dedication', '0','1000','1000','0','0','0','0', '0','0','0','$turntime','$killturn','$age','1', '$personal','$special','$specage','$special2','$specage2','$msg', '0','$bornyear','$deadyear' )", $connect ) or Error(__LINE__.MYDB_error($connect),""); $alllog[0] = "●1월:$name(이)가 성인이 되어 등장했습니다."; pushAllLog($alllog); } } } function SetDevelop($connect, $genType, $no, $city, $tech) { $query = "select rate,pop/pop2*100 as po,comm/comm2*100 as co,def/def2*100 as de,wall/wall2*100 as wa,secu/secu2*100 as se,agri/agri2*100 as ag from city where city='$city'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $city = MYDB_fetch_array($result); // 우선 선정 if($city[rate] < 95) { $command = EncodeCommand(0, 0, 0, 4); // 우선 선정 $query = "update general set turn0='$command' where no='$no'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); return; } $prob = rand() % 100; $command = EncodeCommand(0, 0, 0, 9); //조달 switch($genType) { case 0: //무장 case 2: //무내정장 if($prob < 30) { if($city[de] < 99) { $command = EncodeCommand(0, 0, 0, 5); } //수비 elseif($city[po] < 99) { $command = EncodeCommand(0, 0, 0, 7); } //정장 else { $command = EncodeCommand(0, 0, 0, 9); } //조달 } elseif($prob < 60) { if($city[wa] < 99) { $command = EncodeCommand(0, 0, 0, 6); } //성벽 elseif($city[po] < 99) { $command = EncodeCommand(0, 0, 0, 7); } //정장 else { $command = EncodeCommand(0, 0, 0, 9); } //조달 } elseif($prob < 90) { if($city[se] < 99) { $command = EncodeCommand(0, 0, 0, 8); } //치안 elseif($city[po] < 99) { $command = EncodeCommand(0, 0, 0, 7); } //정장 else { $command = EncodeCommand(0, 0, 0, 9); } //조달 } else { $command = EncodeCommand(0, 0, 0, 29); } break; case 1: //지장 case 3: //지내정장 if($prob < 40) { if($city[ag] < 99) { $command = EncodeCommand(0, 0, 0, 1); } //농업 elseif($tech < 10000) { $command = EncodeCommand(0, 0, 0, 3); } //기술 elseif($city[po] < 99) { $command = EncodeCommand(0, 0, 0, 7); } //정장 else { $command = EncodeCommand(0, 0, 0, 9); } //조달 } elseif($prob < 80) { if($city[co] < 99) { $command = EncodeCommand(0, 0, 0, 2); } //상업 elseif($tech < 10000) { $command = EncodeCommand(0, 0, 0, 3); } //기술 elseif($city[po] < 99) { $command = EncodeCommand(0, 0, 0, 7); } //정장 else { $command = EncodeCommand(0, 0, 0, 9); } //조달 } elseif($prob < 90) { if($tech < 10000) { $command = EncodeCommand(0, 0, 0, 3); } //기술 elseif($city[po] < 99) { $command = EncodeCommand(0, 0, 0, 7); } //정장 else { $command = EncodeCommand(0, 0, 0, 9); } //조달 } else { if($tech < 10000) { $command = EncodeCommand(0, 0, 0, 3 + (rand() % 2) * 6); } //기술, 조달 else { $command = EncodeCommand(0, 0, 0, 29); } } break; } // 장수수가 너무 많으면 탐색 확률 감소 if($command == EncodeCommand(0, 0, 0, 29)) { $query = "select no from general"; $result = MYDB_query($query, $connect) or Error("processAI04 ".MYDB_error($connect),""); $genCount = MYDB_num_rows($result); $ratio = round($genCount / 600 * 100); if(rand() % 100 < $ratio) { $command = EncodeCommand(0, 0, 0, 9); } } $query = "update general set turn0='$command' where no='$no'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); return; } function SetCrew($connect, $no, $personal, $gold, $leader, $genType, $tech, $region, $city, $dex0, $dex10, $dex20, $dex30, $dex40) { switch($genType) { case 0: //무장 case 2: //무내정장 $dex0 = $dex0 + rand()%1000; $dex10 = $dex10 + rand()%1000; $dex20 = $dex20 + rand()%1000; $sel = 0; // 보궁기 선택 if($dex0 > $dex10) { if($dex0 > $dex20) { $sel = 0; } else { $sel = 2; } } else { if($dex10 > $dex20) { $sel = 1; } else { $sel = 2; } } switch($sel) { case 0: $type = 0; //보병 if($tech >= 3000 && $city == 3) { $type = 4; } //근위병 elseif($tech >= 2000 && $city == 64) { $type = 3; } //자객병 elseif($tech >= 1000 && $region == 2) { $type = 1; } //청주병 elseif($tech >= 1000 && $region == 5) { $type = 5; } //등갑병 elseif($tech >= 1000 && $region == 7) { $type = 2; } //수병 break; case 1: $type = 10; //궁병 if($tech >= 3000 && $city == 7) { $type = 14; } //석궁병 elseif($tech >= 3000 && $city == 6) { $type = 13; } //강궁병 elseif($tech >= 1000 && $region == 4) { $type = 12; } //연노병 elseif($tech >= 1000 && $region == 8) { $type = 11; } //궁기병 break; case 2: $type = 20; //기병 if($tech >= 3000 && $city == 2) { $type = 27; } //호표기병 elseif($tech >= 2000 && $city == 63) { $type = 24; } //철기병 elseif($tech >= 2000 && $city == 67) { $type = 25; } //수렵기병 elseif($tech >= 2000 && $city == 65) { $type = 23; } //돌격기병 elseif($tech >= 2000 && $city == 66) { $type = 26; } //맹수병 elseif($tech >= 1000 && $region == 1) { $type = 21; } //백마병 elseif($tech >= 1000 && $region == 3) { $type = 22; } //중장기병 break; } break; case 1: //지장 case 3: //지내정장 $type = 30; //귀병 if($tech >= 3000 && $city == 4) { $type = 34; } //악귀병 elseif($tech >= 3000 && $city == 5) { $type = 37; } //천귀병 elseif($tech >= 3000 && $city == 1) { $type = 38; } //마귀병 elseif($tech >= 2000 && $city == 69) { $type = 33; } //흑귀병 elseif($tech >= 2000 && $city == 68) { $type = 32; } //백귀병 elseif($tech >= 1000 && $region == 6) { $type = 31; } //신귀병 elseif($tech >= 3000 && $city == 3) { $type = 36; } //황귀병 elseif($tech >= 1000 && rand()%100 < 50) { $type = 35; } //남귀병 break; } $gold -= 200; // 사기비용 $cost = getCost($connect, $type) * getTechCost($tech); $cost = CharCost($cost, $personal); $crew = floor($gold / $cost); if($leader < $crew) { $crew = $leader; } $command = EncodeCommand(0, $type, $crew, 11); $query = "update general set turn0='$command' where no='$no'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); return; } function processAI($connect, $no) { global $_baserice; $query = "select startyear,year,month,turnterm,scenario,gold_rate,rice_rate from game where no='1'"; $result = MYDB_query($query, $connect) or Error("processAI00 ".MYDB_error($connect),""); $admin = MYDB_fetch_array($result); // 초반 여부 if($admin[startyear]+2 > $admin[year] || ($admin[startyear]+2 == $admin[year] && $admin[month] < 5)) { $isStart = 1; } else { $isStart = 0; } $query = "select no,turn0,npcid,name,nation,nations,city,level,npcmsg,personal,leader,intel,power,gold,rice,crew,train,atmos,npc,npcmatch,mode,injury,picture,imgsvr,killturn,makelimit,dex0,dex10,dex20,dex30,dex40 from general where no='$no'"; $result = MYDB_query($query, $connect) or Error("processAI01 ".MYDB_error($connect),""); $general = MYDB_fetch_array($result); // 입력된 턴이 있으면 그것 실행 if($general[turn0] != "00000000000000") { return; } $query = "select city,region,nation,level,path,rate,gen1,gen2,gen3,pop,supply,front from city where city='$general[city]'"; $result = MYDB_query($query, $connect) or Error("processAI02 ".MYDB_error($connect),""); $city = MYDB_fetch_array($result); $query = "select nation,level,tech,gold,rice,rate,type,color,name,war from nation where nation='$general[nation]'"; $result = MYDB_query($query, $connect) or Error("processAI03 ".MYDB_error($connect),""); $nation = MYDB_fetch_array($result); if($general[level] >= 5) { $query = "select l{$general[level]}turn0 from nation where nation='$general[nation]'"; $result = MYDB_query($query, $connect) or Error("processAI03 ".MYDB_error($connect),""); $coreCommand = MYDB_fetch_array($result); } $attackable = 0; $query = "select city from city where nation='$general[nation]' and supply='1' and front=1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); // 공격가능도시 있으면 1 if($cityCount > 0) { $attackable = 1; } $dipState = 0; $query = "select no from diplomacy where me='$general[nation]' and state=1 and term>8"; $result = MYDB_query($query, $connect) or Error("processAI04 ".MYDB_error($connect),""); $dipCount = MYDB_num_rows($result); // 선포중이면 1상태 if($dipCount > 0) { $dipState = 1; } $query = "select no from diplomacy where me='$general[nation]' and state=1 and term<=8"; $result = MYDB_query($query, $connect) or Error("processAI04 ".MYDB_error($connect),""); $dipCount = MYDB_num_rows($result); // 전쟁준비 선포중이면 2상태 if($dipCount > 0) { $dipState = 2; } $query = "select no from diplomacy where me='$general[nation]' and state=1 and term<=3"; $result = MYDB_query($query, $connect) or Error("processAI04 ".MYDB_error($connect),""); $dipCount = MYDB_num_rows($result); // 교전 직전이면 3상태 if($dipCount > 0) { $dipState = 3; } $query = "select no from diplomacy where me='$general[nation]' and state=0"; $result = MYDB_query($query, $connect) or Error("processAI04 ".MYDB_error($connect),""); $dipCount = MYDB_num_rows($result); // 교전중이면 4상태 if($dipCount > 0) { $dipState = 4; } //무장 if($general[power] >= $general[intel]) { $genType = 0; if($general[intel] >= $general[power] * 0.8) { //무지장 switch(rand() % 5) { case 0: case 1: case 2: case 3: $genType = 0; break; case 4: $genType = 1; break; } } //지장 } else { $genType = 1; if($general[power] >= $general[intel] * 0.8) { //지무장 switch(rand() % 5) { case 0: $genType = 0; break; case 1: case 2: case 3: case 4: $genType = 1; break; } } } //내정장 if($general[leader] < 40) { $genType += 2; //$genType = 2; // 무내정장 //$genType = 3; // 지내정장 } $tech = getTechCost($nation[tech]); if($general[atmos] >= 90 && $general[train] >= 90) { if($general[mode] == 0) { $query = "update general set mode=1 where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI05 ".MYDB_error($connect),""); } } else { if($general[mode] == 1) { $query = "update general set mode=0 where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI05 ".MYDB_error($connect),""); } } //유기체메시지 출력 하루 6번 //특별 메세지 있는 경우 출력 하루 4번 switch($admin[turnterm]) { case 0: $term = 1; break; case 1: $term = 1; break; case 2: $term = 2; break; case 3: $term = 3; break; case 4: $term = 6; break; case 5: $term = 12; break; case 6: $term = 30; break; case 7: $term = 60; break; } if($general[npcid] == 2000 && rand()%(24*$term) < 6) { PushMsg(1, 0, $general[picture], $general[imgsvr], "{$general[name]}:", $nation[color], $nation[name], $nation[color], $general[npcmsg]); } elseif($general[npcmsg] != "" && rand()%(24*$term) < 3) { PushMsg(1, 0, $general[picture], $general[imgsvr], "{$general[name]}:", $nation[color], $nation[name], $nation[color], $general[npcmsg]); } //재야인경우 if($general[npc] == 5 && $general[level] == 0) { // 오랑캐는 바로 임관 $query = "select nation from general where level=12 and npc=5 and nation not in (0{$general['nations']}0) order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),""); $rulerCount = MYDB_num_rows($result); if($rulerCount > 0) { $ruler = MYDB_fetch_array($result); $command = EncodeCommand(0, 0, $ruler[nation], 25); //임관 } else { $command = EncodeCommand(0, 0, 0, 42); //견문 } $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI07 ".MYDB_error($connect),""); return; } elseif($general[npc] < 5 && $general[level] == 0) { switch(rand()%5) { //임관 40% case 0: case 1: if($admin[scenario] == 0 || $admin[scenario] >= 20) { // 가상모드엔 랜덤임관, 초반엔 부상 적은 군주 우선 70% if($admin[startyear]+3 > $admin[year] && rand()%100 < 70) { $query = "select nation from general where level=12 and nation not in (0{$general['nations']}0) order by injury,rand() limit 0,1"; } else { $query = "select nation from general where level=12 and nation not in (0{$general['nations']}0) order by rand() limit 0,1"; } $result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),""); $rulerCount = MYDB_num_rows($result); if($rulerCount > 0 && $general[npcmatch] != 999 && $general[makelimit] == 0) { $ruler = MYDB_fetch_array($result); $command = EncodeCommand(0, 0, $ruler[nation], 25); //임관 } else { $command = EncodeCommand(0, 0, 0, 42); //견문 } } else { $query = "select nation from general where level=12 and npc=0"; $result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),""); $nonCount = MYDB_num_rows($result); $query = "select nation from general where level=12 and npc>0"; $result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),""); $npcCount = MYDB_num_rows($result); $ratio = round($npcCount / ($nonCount + $npcCount) * 100); $ratio = round($ratio * 1.0); //NPC우선임관 $query = "select nation,ABS(IF(ABS(npcmatch-'$general[npcmatch]')>75,150-ABS(npcmatch-'$general[npcmatch]'),ABS(npcmatch-'$general[npcmatch]'))) as npcmatch2 from general where level=12 and npc>0 and nation not in (0{$general['nations']}0) order by npcmatch2,rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),""); $rulerCount = MYDB_num_rows($result); if($rulerCount > 0 && $general[npcmatch] != 999 && rand()%100 < $ratio && $general[makelimit] == 0) { // 엔국 비율대로 임관(50% : 50%) $ruler = MYDB_fetch_array($result); $command = EncodeCommand(0, 0, $ruler[nation], 25); //임관 } elseif($general[npcmatch] != 999 && $general[makelimit] == 0) { // NPC국가 없으면 유저국 임관 $query = "select nation from general where level=12 and npc=0 order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),""); $ruler = MYDB_fetch_array($result); $command = EncodeCommand(0, 0, $ruler[nation], 25); //임관 } else { $command = EncodeCommand(0, 0, 0, 42); //견문 } } break; case 2: case 3: //거병이나 견문 40% // 초반이면서 능력이 좋은놈 위주로 1%확률로 거병 (300명 재야시 2년간 약 10개 거병 예상) $prop = rand() % 100; $ratio = round(($general[leader] + $general[power] + $general[intel]) / 3); if($admin[startyear]+2 > $admin[year] && $prop < $ratio && rand()%100 < 1 && $general[makelimit] == 0) { //거병 $command = EncodeCommand(0, 0, 0, 55); } else { //견문 $command = EncodeCommand(0, 0, 0, 42); } break; case 4: //이동 20% $paths = explode("|", $city[path]); $command = EncodeCommand(0, 0, $paths[rand()%count($paths)], 21); break; } $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI07 ".MYDB_error($connect),""); return; } $rulerCommand = 0; //군주가 할일 if($general[level] == 12) { //오랑캐인데 공격 못하면 바로 방랑/해산 if($general[npc] == 5 && $dipState == 0 && $attackable == 0) { //방랑군이냐 아니냐 if($nation[level] == 0) { // 해산 $command = EncodeCommand(0, 0, 0, 56); $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); return; } else { // 방랑 $command = EncodeCommand(0, 0, 0, 47); $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); return; } } //분기마다 if($admin[month] == 1 || $admin[month] == 4 || $admin[month] == 7 || $admin[month] == 10) { //관직임명 Promotion($connect, $general[nation], $nation[level]); } elseif($admin[month] == 12) { //세율 $nation[rate] = TaxRate($connect, $general[nation]); //지급율 GoldBillRate($connect, $nation[nation], $nation[rate], $admin[gold_rate], $nation[type], $nation[gold]); } elseif($admin[month] == 6) { //세율 $nation[rate] = TaxRate($connect, $general[nation]); //지급율 RiceBillRate($connect, $nation[nation], $nation[rate], $admin[rice_rate], $nation[type], $nation[rice]); } //방랑군이냐 아니냐 if($nation[level] == 0) { if($admin[startyear]+2 <= $admin[year]) { // 해산 $command = EncodeCommand(0, 0, 0, 56); $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); return; } elseif($city[nation] == 0 && ($city[level] == 5 || $city[level] == 6)) { $type = rand()%9 + 1; $colors = GetNationColors(); $color = rand() % count($colors); $command = EncodeCommand(0, $type, $color, 46); $nationName = "㉿"._String::SubStr($general[name], 1); //건국 $query = "update general set turn0='$command',makenation='$nationName' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI08 ".MYDB_error($connect),""); return; } elseif(rand()%4 > 0) { //이동 $paths = explode("|", $city[path]); $command = EncodeCommand(0, 0, $paths[rand()%count($paths)], 21); $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); return; } else { //조달 $command = EncodeCommand(0, 0, 0, 9); $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); return; } } else { //외교 평시에 선포 if($dipState == 0 && $attackable == 0) { //전방 체크 먼저 SetNationFront($connect, $nation[nation]); $query = "select city from city where nation='$general[nation]' and front=1 limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI02 ".MYDB_error($connect),""); $frontCount = MYDB_num_rows($result); //근접 공백지 없을때 if($frontCount == 0) { $query = "select (sum(pop/10)+sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(pop2/10)+sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2))*100 as dev from city where nation='$general[nation]'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $devRate = MYDB_fetch_array($result); //내정이 80% 이상일때 if($devRate[dev] > 80) { $query = "select nation from nation where level>0 order by rand()"; $result = MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); $nationCount = MYDB_num_rows($result); for($i=0; $i < $nationCount; $i++) { $youNation = MYDB_fetch_array($result); if(isClose($connect, $general[nation], $youNation[nation])) { $command = EncodeCommand(0, 0, $youNation[nation], 62); $query = "update nation set l12turn0='$command' where nation='$general[nation]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); $rulerCommand = 1; break; } } } } } } } // 입력된 턴이 있으면 if($coreCommand["l{$general[level]}turn0"] != EncodeCommand(0, 0, 0, 99)) { $rulerCommand = 1; } //방랑군 아니고, 입력된 턴이 없을때 수뇌부가 할일 if($nation[level] != 0 && $general[level] >= 5 && $rulerCommand == 0) { $query = "select A.no,A.name,A.nation,B.nation from general A, city B where A.city=B.city and A.nation='$general[nation]' and B.nation!='$general[nation]' and A.no!='$general[no]' order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI11 ".MYDB_error($connect),""); $curGen = MYDB_fetch_array($result); if($curGen[no] != 0) { // 타도시에 있는 경우 국내로 발령 if($dipState >= 3) { $query = "select city from city where nation='$general[nation]' and front=1 and supply=1 order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); if($selCity[city] > 0) { // 발령 $command = EncodeCommand(0, $curGen[no], $selCity[city], 27); } else { // 발령 $command = EncodeCommand(0, $curGen[no], $city[city], 27); } } else { // 발령 $command = EncodeCommand(0, $curGen[no], $city[city], 27); } $query = "update nation set l{$general[level]}turn0='$command' where nation='$general[nation]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); } elseif($dipState <= 1) { // 평시엔 균등 발령만 //발령, 최소장수 도시 선택, 최다장수도시의 장수 선택 $query = "select B.city,count(*) as cnt,((B.agri+B.comm+B.secu+B.def+B.wall)/(B.agri2+B.comm2+B.secu2+B.def2+B.wall2)+(B.pop/B.pop2))/2*100 as dev from general A, city B where A.city=B.city and A.nation='$general[nation]' and B.nation='$general[nation]' and B.supply=1 group by A.city"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); //도시 2개 이상일때만 if($cityCount > 1) { $min = 500; $minCity = 0; $max = 0; $maxCity = 0; $devCity = 0; for($i=0; $i < $cityCount; $i++) { $curCity = MYDB_fetch_array($result); if($curCity[cnt] >= $max) { $max = $curCity[cnt]; $maxCity = $curCity[city]; } if($curCity[cnt] <= $min) { $min = $curCity[cnt]; $minCity = $curCity[city]; } if($curCity[dev] < 70) { $devCity = $curCity[city]; } // 개발이 안된 곳 우선 } if($devCity != 0) { $minCity = $devCity; } if($maxCity != $minCity) { $query = "select no from general where city='$maxCity' and nation='$general[nation]' and no!='$general[no]' and npc>=2 limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI11 ".MYDB_error($connect),""); $curGen = MYDB_fetch_array($result); if($curGen[no] != 0) { // 발령 $command = EncodeCommand(0, $curGen[no], $minCity, 27); $query = "update nation set l{$general[level]}turn0='$command' where nation='$general[nation]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); } //계속 진행 } } } else { // 병사있고 쌀있고 후방에 있는 장수 $query = "select A.no from general A, city B where A.city=B.city and A.nation='$general[nation]' and B.nation='$general[nation]' and B.front=0 and A.crew>700 and A.rice>700*{$tech} order by A.npc,A.crew desc limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $selGen = MYDB_fetch_array($result); // 전방 도시, 30% 확률로 태수 있는 전방으로 발령 if(rand()%100 < 30) { $query = "select city from city where nation='$general[nation]' and front=1 and supply=1 order by gen1 desc,rand() limit 0,1"; } else { $query = "select city from city where nation='$general[nation]' and front=1 and supply=1 order by rand() limit 0,1"; } $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); if($selGen[no] > 0 && $selCity[city] > 0 && rand() % 100 < 80) { // 80% 확률 // 발령 $command = EncodeCommand(0, $selGen[no], $selCity[city], 27); } else { //병사 없고 인구없는 전방에 있는 장수 $query = "select A.no from general A, city B where A.city=B.city and A.nation='$general[nation]' and B.nation='$general[nation]' and B.pop<40000 and B.front=1 and A.crew<700 order by A.npc,A.crew limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $selGen = MYDB_fetch_array($result); // 인구많은도시 $query = "select city from city where nation='$general[nation]' and supply=1 order by pop desc limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); if($selGen[no] > 0 && $selCity[city] > 0 && rand() % 100 < 80) { // 80% 확률 // 발령 $command = EncodeCommand(0, $selGen[no], $selCity[city], 27); } else { // 발령할 장수 없으면 몰포 if(rand() % 2 == 0) { $type = "gold"; $type2 = 1; } else { $type = "rice"; $type2 = 2; } if($nation[$type] < 1000) { // 몰수 // 몰수 대상 $query = "select no,{$type} from general where nation='$general[nation]' and no!='$general[no]' and {$type}>3000 order by {$type} desc limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $SelGen = MYDB_fetch_array($result); if($SelGen[no] != 0) { $amount = floor($SelGen[$type] / 5000)*10 + 10; if($amount > 100) $amount = 100; // 몰수 $command = EncodeCommand($type2, $SelGen[no], $amount, 24); // 금,쌀 1000단위 몰수 } } else { // 포상 // 포상 대상 $query = "select no from general where nation='$general[nation]' and no!='$general[no]' and killturn>=5 order by {$type} limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $SelGen = MYDB_fetch_array($result); if($SelGen[no] != 0) { $amount = floor(($nation[$type]-$_baserice) / 5000)*10 + 10; if($amount > 100) $amount = 100; // 포상 $command = EncodeCommand($type2, $SelGen[no], $amount, 23); // 금 1000단위 포상 } } } } $query = "update nation set l{$general[level]}turn0='$command' where nation='$general[nation]'"; MYDB_query($query, $connect) or Error("processAI09 ".MYDB_error($connect),""); } } $command = EncodeCommand(0, 0, 0, 1); //일반 할일 if($general[killturn] < 5) { if($general[gold] + $general[rice] == 0) { $command = EncodeCommand(0, 0, 0, 9); //조달 } elseif($general[gold] > $general[rice]) { $command = EncodeCommand(0, 1, 100, 44); //헌납 } else { $command = EncodeCommand(0, 2, 100, 44); //헌납 } } elseif($general[injury] > 10) { // 부상 2달 이상이면 요양 $command = EncodeCommand(0, 0, 0, 50); //요양 } elseif($nation[level] == 0) { //방랑군일때 if($admin[startyear]+3 <= $admin[year]) { $command = EncodeCommand(0, 0, 0, 45); //하야 } else { switch(rand()%5) { case 0: $command = EncodeCommand(0, 0, 0, 42); break; //견문 20% case 1: case 2: case 3: case 4: $command = EncodeCommand(0, 0, 0, 9); break; //조달 80% } } } else { //국가일때 //아국땅 아니면 귀환 if($general[nation] != $city[nation] || $city[supply] == 0) { $command = EncodeCommand(0, 0, 0, 28); //귀환 $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI23 ".MYDB_error($connect),""); return; } //국가 병량이 없을때 바로 헌납 if($nation[rice] < 2000 && $general[rice] > 200) { $amount = floor(($general[rice] - 200)/100) + 1; if($amount > 20) { $amount = 20; } $command = EncodeCommand(0, 2, $amount, 44); //헌납 $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI23 ".MYDB_error($connect),""); return; } // R // ┃ ┃ 공격/내정 // 700┃쌀┣━━━━┓ // ┃팜┃ ┃ // 100┣━┫ 내정 ┣━━━ // ┃조┃ ┃쌀삼 // 0┗━┻━━━━┻━━━> G // 100 700 $resrc = $tech * 700; // 평시거나 초반아니면서 공격가능 없으면서 병사 있으면 해제(25%) if($dipState == 0 && $isStart == 0 && $attackable == 0 && $general[crew] > 0 && rand()% 100 < 25) { $command = EncodeCommand(0, 0, 0, 17); //소집해제 } elseif($dipState <= 1 || $isStart == 1) { //평시이거나 선포있어도 초반이면 if($general[gold] + $general[rice] < 200) { $command = EncodeCommand(0, 0, 0, 9); } //금쌀없으면 조달9 elseif($general[rice] > 100 && $city[rate] < 95) { $command = EncodeCommand(0, 0, 0, 4); } //우선 선정 elseif($general[gold] < 100) { //금없으면 쌀팜 $amount = floor(($general[rice] - $general[gold]) / 100 / 2); // 100단위 $command = EncodeCommand(0, 1, $amount, 49); //팜 } elseif($general[gold] < 700 && $general[rice] < 700) { $command = EncodeCommand(0, 0, 0, 1); } //금쌀되면 내정 elseif($general[rice] < 100) { //쌀없으면 쌀삼 $amount = floor(($general[gold] - $general[rice]) / 100 / 2); // 100단위 $command = EncodeCommand(0, 2, $amount, 49); //삼 } elseif($genType >= 2) { $command = EncodeCommand(0, 0, 0, 1); } //내정장일때 내정 else { //현도시가 전방이면 공격 가능성 체크 if($city[front] > 0) { //주변도시 체크 $paths = explode("|", $city[path]); for($i=0; $i < count($paths); $i++) { $query = "select city,nation from city where city='$paths[$i]'"; $result = MYDB_query($query, $connect) or Error("processAI20 ".MYDB_error($connect),""); $targetCity = MYDB_fetch_array($result); //공백지이면 타겟에 포함 if($targetCity[nation] == 0) { $target[count($target)] = $targetCity[city]; } } if(count($target) == 0 || $isStart == 1 || $nation[war] == 1) { $command = EncodeCommand(0, 0, 0, 1); } //공격 가능도시가 없으면 내정 else { $command = EncodeCommand(0, 0, $target[rand()%count($target)], 16); } //있으면 공격 } else { //전방 아니면 내정 $command = EncodeCommand(0, 0, 0, 1); } if($command == EncodeCommand(0, 0, 0, 1)) { // 공격아닌 경우 $query = "select city,(pop/10+agri+comm+secu+def+wall)/(pop2/10+agri2+comm2+secu2+def2+wall2)*100 as dev from city where city='$general[city]'"; $result = MYDB_query($query, $connect) or Error("processAI19 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); $sel = rand() % 10; if($selCity[dev] > 95) { $sel = 9; } elseif($selCity[dev] < 70) { $sel = 0; } switch($sel) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: // 그대로 내정 80 % $command = EncodeCommand(0, 0, 0, 1); break; case 8: case 9: // 저개발 도시로 워프 20% //도시 선택, 30% 확률로 군사 있는 곳으로 워프 if(rand()%100 < 30) { $query = "select city,(pop/10+agri+comm+secu+def+wall)/(pop2/10+agri2+comm2+secu2+def2+wall2)*100 as dev from city where nation='$general[nation]' and supply='1' order by gen2 desc,dev limit 0,1"; } else { $query = "select city,(pop/10+agri+comm+secu+def+wall)/(pop2/10+agri2+comm2+secu2+def2+wall2)*100 as dev from city where nation='$general[nation]' and supply='1' order by dev limit 0,1"; } $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); //이미 그 도시이거나, 그 도시도 고개발이면 내정 if($selCity[city] == $general[city] || $selCity[dev] > 95) { $command = EncodeCommand(0, 0, 0, 1); } else { //워프 $query = "update general set city='$selCity[city]' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI18 ".MYDB_error($connect),""); $command = EncodeCommand(0, 0, 0, 50); //요양 $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI23 ".MYDB_error($connect),""); return; } break; } // ┃ ┃ // ┃ 쌀팜 ┃ 공격 // ┃ ┃ // 700t┣━━━━╋━━━━━━━━━ // ┃내조 ↗┃ // ┃ ↗ ┃ // ┣━┓내조┃ 쌀삼 // ┃**┃ ┃ // 0 ┗━┻━━━━━━━> G // 700t } else { // 공격인 경우 if($general[crew] < 700 && $general[gold] >= $resrc && $general[rice] >= $resrc) { //자원되고, 병사없을때 if($city[pop] > 40000) { $command = EncodeCommand(0, 0, 0, 11); } else { $command = EncodeCommand(0, 0, 0, 1); } } elseif($general[rice] < $resrc && $general[rice] <= $general[gold]) { //금이 더 많으면 매매 $amount = floor(($general[gold] - $general[rice]) / 100 / 2); // 100단위 if($amount > 0) { $command = EncodeCommand(0, 2, $amount, 49); }//삼 else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); } // 내정, 조달 } elseif($general[gold] < $resrc && $general[rice] > $general[gold]) { //쌀이 더 많으면 매매 $amount = floor(($general[rice] - $general[gold]) / 100 / 2); // 100단위 if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }//팜 else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); } // 내정, 조달 //자원, 병사 모두 충족 } elseif($general[crew] >= 700 && $general[train] < 90) { $command = EncodeCommand(0, 0, 0, 13); //훈련 } elseif($general[crew] >= 700 && $general[atmos] < 90) { $command = EncodeCommand(0, 0, 0, 14); //사기진작 } else { //공격 //$command = $target[rand()%count($target)] * 100 + 16; //있으면 공격 } } } } else { // R // ┃ ┃ // ┃쌀┃ // ┃팜┃ 공격 // 700t┣━╋━━━━━ // ┃조┃ 쌀삼 // 0┗━┻━━━━━> G // 700t //전시일때 if($general[gold] + $general[rice] < $resrc*2) { $command = EncodeCommand(0, 0, 0, 9); } //금쌀없으면 조달 elseif($general[rice] > $resrc && $city[rate] < 95 && $city[front] == 0) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정 elseif($general[rice] > $resrc && $city[rate] < 50 && $city[front] == 1) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정 elseif($general[gold] < $resrc) { // 금없으면 쌀팜 $amount = floor(($general[rice] - $general[gold]) / 100 / 2); // 100단위 if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }// 팜 else { $command = EncodeCommand(0, 0, 0, 9); } // 조달 } elseif($general[rice] < $resrc) { // 쌀없으면 쌀삼 $amount = floor(($general[gold] - $general[rice]) / 100 / 2); // 100단위 if($amount > 0) { $command = EncodeCommand(0, 2, $amount, 49); }// 팜 else { $command = EncodeCommand(0, 0, 0, 9); } // 조달 } elseif($genType >= 2) { $command = EncodeCommand(0, 0, 0, 1); } //내정장일때 내정 elseif($general[crew] < 700 && $general[gold] >= $resrc && $general[rice] >= $resrc) { $query = "select no from general where nation='$general[nation]'"; $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $genCount = MYDB_num_rows($result); $query = "select no from general where nation='$general[nation]' and city='$general[city]'"; $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $genCount2 = MYDB_num_rows($result); $query = "select sum(pop) as sum from city where nation='$general[nation]' and supply='1'"; $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $sumCity = MYDB_fetch_array($result); // 현도시 인구 비율 $ratio = round($city[pop] / $sumCity[sum] * 100); // 현도시 장수 비율 $ratio2 = round($genCount2 / $genCount * 100); $ratio3 = rand() % 100; // 전체 인구 대비 확률로 현지에서 징병 if($city[pop] > 40000 && 100 + $ratio - $ratio2 > $ratio3) { $command = EncodeCommand(0, 0, 0, 11); //인구 되면 징병 } else { // 인구 안되면 4만 이상인 도시로 워프 $query = "select city from city where nation='$general[nation]' and pop>40000 and supply='1' order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); if($cityCount > 0) { $selCity = MYDB_fetch_array($result); //워프 $query = "update general set city='$selCity[city]' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI18 ".MYDB_error($connect),""); $command = EncodeCommand(0, 0, 0, 50); //요양 $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI23 ".MYDB_error($connect),""); return; } else { $command = EncodeCommand(0, 0, 0, 7); //인구 안되면 정장 } } } elseif($general[crew] >= 700 && $general[train] < 90) { if($general[atmos] >= 90 && $general[train] >= 60 && $general[mode] == 0) { $query = "update general set mode=1 where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI05 ".MYDB_error($connect),""); } $command = EncodeCommand(0, 0, 0, 13); //훈련 } elseif($general[crew] >= 700 && $general[atmos] < 90) { if($general[atmos] >= 60 && $general[train] >= 90 && $general[mode] == 0) { $query = "update general set mode=1 where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI05 ".MYDB_error($connect),""); } $command = EncodeCommand(0, 0, 0, 14); //사기진작 } elseif($dipState <= 3) { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); // 준비는 됐으나 아직 선포중이면 내정, 조달 } else { //공격 & 내정 $paths = explode("|", $city[path]); for($i=0; $i < count($paths); $i++) { $query = "select city,nation from city where city='$paths[$i]'"; $result = MYDB_query($query, $connect) or Error("processAI21 ".MYDB_error($connect),""); $targetCity = MYDB_fetch_array($result); //소유국이 있는 경우 if($targetCity[nation] != 0 && $targetCity[nation] != $general[nation]) { $query = "select state from diplomacy where me='$general[nation]' and you='$targetCity[nation]'"; $dipResult = MYDB_query($query, $connect) or Error("processAI22 ".MYDB_error($connect),""); $dip = MYDB_fetch_array($dipResult); //전쟁중인 국가이면 타겟에 포함 if($dip[state] == 0) $target[count($target)] = $targetCity[city]; } } if(count($target) == 0) { //전방 도시 선택, 30% 확률로 태수 있는 전방으로 워프 if(rand()%100 < 30) { $query = "select city from city where nation='$general[nation]' and supply='1' and front=1 order by gen1 desc,rand() limit 0,1"; } else { $query = "select city from city where nation='$general[nation]' and supply='1' and front=1 order by rand() limit 0,1"; } $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); if($cityCount == 0) { //도시 수, 랜덤(상위 20%) 선택, 저개발 도시 선택 $query = "select city from city where nation='$general[nation]' and supply='1'"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); $citySelect = rand() % (round($cityCount/5) + 1); $query = "select city,(def+wall)/(def2+wall2) as dev from city where nation='$general[nation]' and supply='1' order by dev limit {$citySelect},1"; $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); } else { $selCity = MYDB_fetch_array($result); } if($general[city] != $selCity[city]) { //워프 $query = "update general set city='$selCity[city]' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI18 ".MYDB_error($connect),""); $command = EncodeCommand(0, 0, 0, 50); //요양 $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI23 ".MYDB_error($connect),""); return; } else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); //공격 가능도시가 없고 워프도 안되면 내정, 조달 } } elseif($nation[war] == 1) { //전금이면 내정, 조달 $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); //내정, 조달 } else { $command = EncodeCommand(0, 0, $target[rand()%count($target)], 16); } //있으면 공격 } } } switch($command) { case "00000000000001": //내정 SetDevelop($connect, $genType, $general[no], $general[city], $nation[tech]); return; case "00000000000011": //징병 $query = "select region from city where nation='$general[nation]' order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $selRegion = MYDB_fetch_array($result); $selCity[city] = 0; // 90% 확률로 이민족 또는 특성병 if(rand()%100 < 90) { $query = "select city from city where nation='$general[nation]' and (level='4' or level='8') order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),""); $selCity = MYDB_fetch_array($result); } // 특병 없으면 원래대로 if($selCity[city] == 0) { $selCity[city] = $general[city]; } SetCrew($connect, $general[no], $general[personal], $general[gold], $general[leader], $genType, $nation[tech], $selRegion[region], $selCity[city], $general[dex0], $general[dex10], $general[dex20], $general[dex30], $general[dex40]); return; default: $query = "update general set turn0='$command' where no='$general[no]'"; MYDB_query($query, $connect) or Error("processAI23 ".MYDB_error($connect),""); return; } } //종전하기, 지급율 //$command = $fourth * 100000000 + $type * 100000 + $crew * 100 + 11; function RegNation($connect, $name, $color, $gold, $rice, $scoutmsg, $tech, $gencount, $type, $level) { $type = NationCharCall($type); $totaltech = $tech * $gencount; @MYDB_query(" insert into nation ( name,color,gold,rice,bill,rate,scout,war,tricklimit,surlimit, scoutmsg,tech,totaltech,type,level,gennum ) values ( '$name','$color','$gold','$rice','100','15','0','0','24','72', '$scoutmsg','$tech','$totaltech','$type','$level','$gencount' )", $connect ) or Error(__LINE__.MYDB_error($connect),""); } function RegCity($connect, $nation, $name, $cap=0) { $city = CityCall($name); @MYDB_query("update city set nation='$nation' where city='$city'",$connect) or Error(__LINE__.MYDB_error($connect),""); if($cap > 0) { @MYDB_query("update nation set capital='$city' where nation='$nation'",$connect) or Error(__LINE__.MYDB_error($connect),""); } } function Promotion($connect, $nation, $level) { $lv = getNationChiefLevel($level); $query = "select scenario,killturn from game where no='1'"; $result = MYDB_query($query, $connect) or Error("processAI00 ".MYDB_error($connect),""); $admin = MYDB_fetch_array($result); //우선 수뇌 해제 (승상 뺴고) $query = "update general set level=1 where level<11 and level>4 and nation='$nation'"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); //유저 후보 선택 $query = "select no from general where nation='$nation' and npc<2 and level=1 and belong>=3 and killturn>='$admin[killturn]' order by rand() limit 0,1"; $result = MYDB_query($query, $connect) or Error("Promotion_00 ".MYDB_error($connect),""); $userCandidate = MYDB_fetch_array($result); // 유저수뇌 안함 //$userCandidate[no] = 0; //NPC 후보 선택 $query = "select no from general where nation='$nation' and npc>=2 and level=1 order by intel desc limit 0,1"; $result = MYDB_query($query, $connect) or Error("Promotion_00 ".MYDB_error($connect),""); $npcCandidate = MYDB_fetch_array($result); //현재 참모 $query = "select no,intel,npc,killturn from general where nation='$nation' and level=11"; $result = MYDB_query($query, $connect) or Error("Promotion_00 ".MYDB_error($connect),""); $level11 = MYDB_fetch_array($result); //공석이거나 삭턴 유저 참모인 경우 if($level11[no] == 0 || ($level11[npc] < 2 && $level11[killturn] < $admin[killturn])) { if($userCandidate[no] > 0) { //기존 참모 해임 $query = "update general set level=1 where nation='$nation' and level=11"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); //유저 후보 있으면 임명 $query = "update general set level=11 where no='$userCandidate[no]'"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); } elseif($npcCandidate[no] > 0) { //기존 참모 해임 $query = "update general set level=1 where nation='$nation' and level=11"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); //NPC 후보 있으면 임명 $query = "update general set level=11 where no='$npcCandidate[no]'"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); } } elseif($level11[npc] >= 2 && $userCandidate[no] > 0) { //NPC 참모인데 삭턴 아닌 유저장이 있는 경우 //기존 참모 해임 $query = "update general set level=1 where nation='$nation' and level=11"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); //유저 후보 있으면 임명 $query = "update general set level=11 where no='$userCandidate[no]'"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); } for($i=10; $i >= $lv; $i-=2) { $i1 = $i; $i2 = $i - 1; //무관임명 $query = "select no from general where nation='$nation' and level=1 order by power desc limit 0,1"; $result = MYDB_query($query, $connect) or Error("Promotion_00 ".MYDB_error($connect),""); $level = MYDB_fetch_array($result); $query = "update general set level={$i1} where no='$level[no]'"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); //문관임명 $query = "select no from general where nation='$nation' and level=1 order by intel desc limit 0,1"; $result = MYDB_query($query, $connect) or Error("Promotion_00 ".MYDB_error($connect),""); $level = MYDB_fetch_array($result); $query = "update general set level={$i2} where no='$level[no]'"; MYDB_query($query, $connect) or Error("Promotion_02 ".MYDB_error($connect),""); } } function TaxRate($connect, $nation) { //도시 $query = "select city from city where nation='$nation'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); if($cityCount == 0) { $query = "update nation set war=0,rate=15 where nation='$nation'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); return 15; } else { $query = "select sum(pop)/sum(pop2)*100 as rate,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2))*100 as dev from city where nation='$nation'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $devRate = MYDB_fetch_array($result); $avg = ($devRate[rate] + $devRate[dev]) / 2; if($avg > 95) $rate = 25; elseif($avg > 70) $rate = 20; elseif($avg > 50) $rate = 15; else $rate = 10; $query = "update nation set war=0,rate='$rate' where nation='$nation'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); return $rate; } } function GoldBillRate($connect, $nation, $rate, $gold_rate, $type, $gold) { $incomeList = getGoldIncome($connect, $nation, $rate, $gold_rate, $type); $income = $gold + $incomeList[0] + $incomeList[1]; $outcome = getGoldOutcome($connect, $nation, 100); // 100%의 지급량 $bill = floor($income / $outcome * 90); // 수입의 90% 만 지급 if($bill < 20) { $bill = 20; } if($bill > 200) { $bill = 200; } $query = "update nation set bill='$bill' where nation='$nation'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } function RiceBillRate($connect, $nation, $rate, $rice_rate, $type, $rice) { $incomeList = getRiceIncome($connect, $nation, $rate, $rice_rate, $type); $income = $rice + $incomeList[0] + $incomeList[1]; $outcome = getRiceOutcome($connect, $nation, 100); // 100%의 지급량 $bill = floor($income / $outcome * 90); // 수입의 90% 만 지급 if($bill < 20) { $bill = 20; } if($bill > 200) { $bill = 200; } $query = "update nation set bill='$bill' where nation='$nation'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } ?>