File size: 31,936 Bytes
89dc309 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | """
کلاس اصلی بازی که سیستمهای مختلف را مدیریت میکند
"""
import time
from game_state import GameState
from calendar.calendar_system import CalendarSystem
from climate.climate_system import ClimateSystem
from demographics.population_system import PopulationSystem
from technology.research_system import ResearchSystem
from religion.religious_system import ReligiousSystem
from espionage.espionage_system import EspionageSystem
from cities.city_management import CityManagement
from warfare.warfare_system import WarfareSystem
from trade.trade_system import TradeSystem
from politics.domestic_policy import DomesticPolicy
from society.happiness_system import HappinessSystem
from culture.cultural_system import CulturalSystem
from diplomacy.diplomacy_system import DiplomacySystem
from economy.macro_economy import MacroEconomy
from military.army_management import ArmyManagement
from health.healthcare_system import HealthcareSystem
from education.education_system import EducationSystem
from environment.environmental_system import EnvironmentalSystem
from crisis.crisis_management import CrisisManagement
from succession.succession_system import SuccessionSystem
from achievements.achievements_system import AchievementsSystem
from ui.console_ui import ConsoleUI
from utils.save_load import SaveLoadManager
from config import GAME_CONFIG, UI_CONFIG, ADVANCED_CONFIG
class EmpireGame:
"""کلاس اصلی بازی سایههای امپراتوری"""
def __init__(self):
"""ساخت یک نمونه جدید از بازی"""
self.game_state = GameState()
self.calendar = CalendarSystem(self.game_state)
self.climate = ClimateSystem(self.game_state)
self.population = PopulationSystem(self.game_state)
self.technology = ResearchSystem(self.game_state)
self.religion = ReligiousSystem(self.game_state)
self.espionage = EspionageSystem(self.game_state)
self.cities = CityManagement(self.game_state)
self.warfare = WarfareSystem(self.game_state)
self.trade = TradeSystem(self.game_state)
self.politics = DomesticPolicy(self.game_state)
self.society = HappinessSystem(self.game_state)
self.culture = CulturalSystem(self.game_state)
self.diplomacy = DiplomacySystem(self.game_state)
self.economy = MacroEconomy(self.game_state)
self.military = ArmyManagement(self.game_state)
self.health = HealthcareSystem(self.game_state)
self.education = EducationSystem(self.game_state)
self.environment = EnvironmentalSystem(self.game_state)
self.crisis = CrisisManagement(self.game_state)
self.succession = SuccessionSystem(self.game_state)
self.achievements = AchievementsSystem(self.game_state)
self.save_manager = SaveLoadManager()
self.running = False
self.plugins = []
self.difficulty = "normal"
self.undo_stack = []
self.redo_stack = []
def start(self):
"""شروع بازی و ورود به حلقه اصلی"""
self.running = True
ConsoleUI.clear_screen()
# نمایش مقدمه بازی
ConsoleUI.display_intro()
# انتخاب سطح دشواری
self.select_difficulty()
# انتخاب کشور توسط بازیکن
self.game_state.select_country()
# راهاندازی سیستمهای بازی
self.initialize_game_systems()
# نمایش راهنما
self.show_tutorial()
# ورود به حلقه اصلی بازی
self.game_loop()
def select_difficulty(self):
"""انتخاب سطح دشواری بازی"""
ConsoleUI.clear_screen()
ConsoleUI.display_section_title("انتخاب سطح دشواری")
difficulties = ["آسان", "معمولی", "سخت"]
choice = ConsoleUI.get_menu_choice(difficulties)
if choice == 1:
self.difficulty = "easy"
elif choice == 2:
self.difficulty = "normal"
else:
self.difficulty = "hard"
# اعمال ضرایب دشواری
self.game_state.difficulty = self.difficulty
self.game_state.difficulty_factors = GAME_CONFIG["difficulty_levels"][self.difficulty]
ConsoleUI.display_success(f"سطح دشواری '{difficulties[choice-1]}' انتخاب شد.")
time.sleep(1)
def initialize_game_systems(self):
"""راهاندازی اولیه سیستمهای بازی"""
# راهاندازی سیستمهای مختلف بازی
self.calendar.initialize()
self.climate.initialize()
self.population.initialize()
self.technology.initialize()
self.religion.initialize()
self.espionage.initialize()
self.cities.initialize()
self.warfare.initialize()
self.trade.initialize()
self.politics.initialize()
self.society.initialize()
self.culture.initialize()
self.diplomacy.initialize()
self.economy.initialize()
self.military.initialize()
self.health.initialize()
self.education.initialize()
self.environment.initialize()
self.crisis.initialize()
self.succession.initialize()
self.achievements.initialize()
# نمایش وضعیت اولیه
ConsoleUI.display_country_info(self.game_state.player_country)
def game_loop(self):
"""حلقه اصلی بازی"""
while self.running:
try:
ConsoleUI.clear_screen()
# نمایش وضعیت فعلی بازی
ConsoleUI.display_game_status(self.game_state)
# بررسی شرایط پایان بازی
if self.check_victory_conditions():
break
# پردازش رویدادهای سالانه
self.process_yearly_events()
# پردازش اقدامات بازیکن
self.process_player_actions()
# بهروزرسانیهای سالانه
self.annual_updates()
# افزایش سال
self.game_state.current_year += 1
# ذخیره خودکار
if self.game_state.current_year % GAME_CONFIG["auto_save_interval"] == 0:
self.save_manager.auto_save(self.game_state)
except KeyboardInterrupt:
# مدیریت خروج با Ctrl+C
if ConsoleUI.confirm_action("آیا میخواهید بازی را ذخیره و خارج شوید؟"):
self.save_manager.save_game(self.game_state)
ConsoleUI.display_message("بازی ذخیره شد. خداحافظ!")
break
else:
ConsoleUI.display_warning("ادامه بازی...")
except Exception as e:
ConsoleUI.display_error(f"خطای غیرمنتظره: {str(e)}")
if ConsoleUI.confirm_action("آیا میخواهید بازی را ذخیره و خارج شوید؟"):
self.save_manager.save_game(self.game_state)
break
def process_yearly_events(self):
"""پردازش رویدادهای سالانه"""
# بررسی احتمال وقوع رویدادهای مختلف
if self.game_state.random.random() < GAME_CONFIG["event_probability"]["common"]:
event = self.calendar.select_random_event()
if event:
ConsoleUI.display_event(event)
choice = ConsoleUI.get_player_choice(event["choices"])
self.calendar.apply_event_choice(event, choice)
# بررسی احتمال وقوع رویدادهای آبوهوایی
if self.game_state.random.random() < GAME_CONFIG["event_probability"]["rare"]:
event = self.climate.select_weather_event()
if event:
ConsoleUI.display_weather_event(event)
choice = ConsoleUI.get_player_choice(event["choices"])
self.climate.apply_weather_event_choice(event, choice)
# بررسی احتمال وقوع رویدادهای تاریخی
if self.game_state.random.random() < GAME_CONFIG["event_probability"]["historical"]:
event = self.calendar.select_historical_event()
if event:
ConsoleUI.display_historical_event(event)
choice = ConsoleUI.get_player_choice(event["choices"])
self.calendar.apply_historical_event_choice(event, choice)
def process_player_actions(self):
"""پردازش اقدامات بازیکن"""
main_actions = [
"مشاهده وضعیت کشور",
"مدیریت اقتصاد",
"دیپلماسی و روابط خارجی",
"مدیریت نظامی",
"سیاست داخلی",
"مدیریت شهرها",
"سیستم فناوری",
"سیستم فرهنگی",
"سیستم دینی",
"سیستم جمعیت",
"ذخیره بازی",
"بازیابی آخرین اقدام (Undo)",
"خروج از بازی"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("اقدامات اصلی")
choice = ConsoleUI.get_menu_choice(main_actions)
if choice == 1:
self.handle_country_status()
elif choice == 2:
self.handle_economy_management()
elif choice == 3:
self.handle_diplomacy()
elif choice == 4:
self.handle_military()
elif choice == 5:
self.handle_domestic_policy()
elif choice == 6:
self.handle_city_management()
elif choice == 7:
self.handle_technology()
elif choice == 8:
self.handle_culture()
elif choice == 9:
self.handle_religion()
elif choice == 10:
self.handle_population()
elif choice == 11:
self.save_manager.save_game(self.game_state)
ConsoleUI.display_success("بازی با موفقیت ذخیره شد!")
time.sleep(1)
elif choice == 12:
self.undo_last_action()
elif choice == 13:
if ConsoleUI.confirm_action("آیا میخواهید بازی را ذخیره و خارج شوید؟"):
self.save_manager.save_game(self.game_state)
self.running = False
return
def handle_country_status(self):
"""مدیریت نمایش وضعیت کشور"""
ConsoleUI.clear_screen()
ConsoleUI.display_section_title("وضعیت کشور")
ConsoleUI.display_country_status(self.game_state)
ConsoleUI.wait_for_enter()
def handle_economy_management(self):
"""مدیریت اقتصاد کشور"""
economy_actions = [
"مدیریت مالیات و بودجه",
"سرمایهگذاری در زیرساخت",
"تجارت با کشورهای دیگر",
"مدیریت منابع طبیعی",
"سیاستهای اقتصادی کلان",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("مدیریت اقتصاد")
choice = ConsoleUI.get_menu_choice(economy_actions)
if choice == 1:
self.economy.manage_taxes()
elif choice == 2:
self.economy.invest_in_infrastructure()
elif choice == 3:
self.trade.trade_with_countries()
elif choice == 4:
self.economy.manage_resources()
elif choice == 5:
self.economy.set_economic_policy()
elif choice == 6:
return
def handle_diplomacy(self):
"""مدیریت دیپلماسی و روابط خارجی"""
diplomacy_actions = [
"مشاهده روابط فعلی",
"پیشنهاد اتحاد یا پیمان",
"مذاکره برای صلح",
"ارسال سفیر و ایجاد سفارتخانه",
"عضویت در سازمانهای بینالمللی",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("دیپلماسی")
choice = ConsoleUI.get_menu_choice(diplomacy_actions)
if choice == 1:
self.diplomacy.display_relations()
elif choice == 2:
self.diplomacy.propose_alliance()
elif choice == 3:
self.diplomacy.negotiate_peace()
elif choice == 4:
self.diplomacy.send_envoy()
elif choice == 5:
self.diplomacy.join_international_orgs()
elif choice == 6:
return
def handle_military(self):
"""مدیریت امور نظامی"""
military_actions = [
"مشاهده نیروهای نظامی",
"آموزش ارتش",
"تولید تسلیحات",
"حمله به کشور دیگر",
"دفاع از قلمرو",
"استراتژیهای نظامی",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("مدیریت نظامی")
choice = ConsoleUI.get_menu_choice(military_actions)
if choice == 1:
self.military.display_forces()
elif choice == 2:
self.military.train_army()
elif choice == 3:
self.military.produce_weapons()
elif choice == 4:
self.warfare.attack_country()
elif choice == 5:
self.warfare.defend_territory()
elif choice == 6:
self.warfare.select_military_tactics()
elif choice == 7:
return
def handle_domestic_policy(self):
"""مدیریت سیاست داخلی"""
politics_actions = [
"مدیریت احزاب و گروههای فشار",
"اجرای اصلاحات اجتماعی",
"سیاستهای بهداشت و درمان",
"سیاستهای آموزشی",
"انتخابات و حکومتهای مردمی",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("سیاست داخلی")
choice = ConsoleUI.get_menu_choice(politics_actions)
if choice == 1:
self.politics.manage_political_parties()
elif choice == 2:
self.politics.implement_social_reforms()
elif choice == 3:
self.health.manage_healthcare()
elif choice == 4:
self.education.manage_education()
elif choice == 5:
self.politics.hold_elections()
elif choice == 6:
return
def handle_city_management(self):
"""مدیریت شهرها"""
city_actions = [
"مشاهده شهرها",
"ساخت بناهای جدید",
"مدیریت جمعیت شهری",
"برنامهریزی شهری",
"مدیریت بحرانهای شهری",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("مدیریت شهرها")
choice = ConsoleUI.get_menu_choice(city_actions)
if choice == 1:
self.cities.display_cities()
elif choice == 2:
self.cities.build_new_structures()
elif choice == 3:
self.population.manage_urban_population()
elif choice == 4:
self.cities.city_planning()
elif choice == 5:
self.crisis.manage_city_crises()
elif choice == 6:
return
def handle_technology(self):
"""مدیریت سیستم فناوری"""
tech_actions = [
"مشاهده درخت فناوری",
"تحقیق در فناوریهای جدید",
"مدیریت مراکز تحقیقاتی",
"همکاریهای فناوری",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("سیستم فناوری")
choice = ConsoleUI.get_menu_choice(tech_actions)
if choice == 1:
self.technology.display_tech_tree()
elif choice == 2:
self.technology.conduct_research()
elif choice == 3:
self.technology.manage_research_centers()
elif choice == 4:
self.technology.technology_cooperation()
elif choice == 5:
return
def handle_culture(self):
"""مدیریت سیستم فرهنگی"""
culture_actions = [
"مشاهده وضعیت فرهنگی",
"سرمایهگذاری در گسترش فرهنگ",
"فرهنگسازی در کشورهای تحت کنترل",
"مدیریت زبان و هنر",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("گسترش فرهنگ")
choice = ConsoleUI.get_menu_choice(culture_actions)
if choice == 1:
self.culture.display_culture_status()
elif choice == 2:
self.culture.invest_in_cultural_spread()
elif choice == 3:
self.culture.cultural_assimilation()
elif choice == 4:
self.culture.manage_language_and_art()
elif choice == 5:
return
def handle_religion(self):
"""مدیریت سیستم دینی"""
religion_actions = [
"مشاهده وضعیت دینی",
"گسترش دین",
"مدیریت گروههای مذهبی",
"اجرای سیاستهای دینی",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("سیستم دینی")
choice = ConsoleUI.get_menu_choice(religion_actions)
if choice == 1:
self.religion.display_religious_status()
elif choice == 2:
self.religion.spread_religion()
elif choice == 3:
self.religion.manage_religious_groups()
elif choice == 4:
self.religion.implement_religious_policies()
elif choice == 5:
return
def handle_population(self):
"""مدیریت سیستم جمعیت"""
population_actions = [
"مشاهده ساختار جمعیت",
"مدیریت مهاجرت",
"برنامهریزی خانواده",
"مدیریت طبقات اجتماعی",
"برگشت"
]
while True:
ConsoleUI.clear_screen()
ConsoleUI.display_game_status(self.game_state)
ConsoleUI.display_section_title("سیستم جمعیت")
choice = ConsoleUI.get_menu_choice(population_actions)
if choice == 1:
self.population.display_population_structure()
elif choice == 2:
self.population.manage_migration()
elif choice == 3:
self.population.family_planning()
elif choice == 4:
self.society.manage_social_classes()
elif choice == 5:
return
def annual_updates(self):
"""بهروزرسانیهای سالانه بازی"""
# بهروزرسانی تقویم
self.calendar.annual_update()
# بهروزرسانی آبوهوایی
self.climate.annual_update()
# بهروزرسانی جمعیت
self.population.annual_update()
# بهروزرسانی فناوری
self.technology.annual_update()
# بهروزرسانی دینی
self.religion.annual_update()
# بهروزرسانی جاسوسی
self.espionage.annual_update()
# بهروزرسانی شهرها
self.cities.annual_update()
# بهروزرسانی نظامی
self.warfare.annual_update()
# بهروزرسانی تجارت
self.trade.annual_update()
# بهروزرسانی سیاست داخلی
self.politics.annual_update()
# بهروزرسانی اجتماعی
self.society.annual_update()
# بهروزرسانی فرهنگی
self.culture.annual_update()
# بهروزرسانی دیپلماسی
self.diplomacy.annual_update()
# بهروزرسانی اقتصاد کلان
self.economy.annual_update()
# بهروزرسانی نظامی
self.military.annual_update()
# بهروزرسانی بهداشت
self.health.annual_update()
# بهروزرسانی آموزش
self.education.annual_update()
# بهروزرسانی محیط زیست
self.environment.annual_update()
# بهروزرسانی مدیریت بحران
self.crisis.annual_update()
# بهروزرسانی جانشینی
self.succession.annual_update()
# بهروزرسانی دستاوردها
self.achievements.annual_update()
# بررسی شرایط پایان بازی
self.check_victory_conditions()
def check_victory_conditions(self):
"""بررسی شرایط پیروزی یا شکست"""
# تسلط جهانی
if self.game_state.controlled_territories >= GAME_CONFIG["victory_conditions"]["world_domination"]:
self.show_victory_screen("تسلط جهانی",
"شما موفق شدید بیش از نصف کشورهای جهان را تحت کنترل خود درآورید!")
return True
# تسلط اقتصادی
if self.game_state.gold >= GAME_CONFIG["victory_conditions"]["economic_domination"]:
self.show_victory_screen("تسلط اقتصادی",
"شما به غنیترین کشور جهان تبدیل شدید و اقتصاد جهانی را کنترل میکنید!")
return True
# تسلط فرهنگی
if self.game_state.culture_score >= GAME_CONFIG["victory_conditions"]["cultural_domination"]:
self.show_victory_screen("تسلط فرهنگی",
"فرهنگ و زبان شما به تمام نقاط جهان گسترش یافت!")
return True
# تسلط فناوری
if self.game_state.technology_level >= GAME_CONFIG["victory_conditions"]["technological_domination"]:
self.show_victory_screen("تسلط فناوری",
"شما به پیشرفتهترین کشور جهان تبدیل شدید و فناوری را کنترل میکنید!")
return True
# تسلط دینی
if self.game_state.religious_influence >= GAME_CONFIG["victory_conditions"]["religious_domination"]:
self.show_victory_screen("تسلط دینی",
"دین شما به بیش از 75% جمعیت جهان گسترش یافت!")
return True
# شرایط شکست
if self.game_state.political_stability <= 0:
self.show_defeat_screen("ناپایداری سیاسی",
"ثبات سیاسی شما به صفر رسید و مردم علیه شما شورش کردند!")
return True
if self.game_state.gold <= 0:
self.show_defeat_screen("ورشکستگی مالی",
"منابع مالی شما به پایان رسید و امپراتوری شما از بین رفت!")
return True
# بررسی سال پایانی
if self.game_state.current_year >= GAME_CONFIG["max_year"]:
self.show_defeat_screen("پایان دوره تاریخی",
f"شما توانستید تا سال {GAME_CONFIG['max_year']} دوام بیاورید، اما هنوز به پیروزی نرسیدید.")
return True
return False
def show_victory_screen(self, victory_type, description):
"""نمایش صفحه پیروزی"""
ConsoleUI.clear_screen()
ConsoleUI.display_section_title("پیروزی!")
ConsoleUI.display_success(f"تبریک! شما با {victory_type} پیروز شدید!")
ConsoleUI.display_message(description)
ConsoleUI.display_message(f"سال پایانی: {self.game_state.current_year}")
ConsoleUI.display_message(f"ثروت نهایی: {self.game_state.gold} سکه طلا")
ConsoleUI.display_message(f"امتیاز فرهنگی: {self.game_state.culture_score}/100")
ConsoleUI.display_message(f"سطح فناوری: {self.game_state.technology_level}")
ConsoleUI.display_message(f"نفوذ دینی: {self.game_state.religious_influence}%")
# ذخیره نتیجه بازی
self.save_manager.save_game_result(self.game_state, victory_type)
ConsoleUI.wait_for_enter()
self.running = False
def show_defeat_screen(self, defeat_type, description):
"""نمایش صفحه شکست"""
ConsoleUI.clear_screen()
ConsoleUI.display_section_title("شکست")
ConsoleUI.display_error(f"متأسفانه با {defeat_type} باختید!")
ConsoleUI.display_message(description)
ConsoleUI.display_message(f"سال پایانی: {self.game_state.current_year}")
ConsoleUI.display_message(f"ثروت نهایی: {self.game_state.gold} سکه طلا")
ConsoleUI.display_message(f"امتیاز فرهنگی: {self.game_state.culture_score}/100")
ConsoleUI.display_message(f"سطح فناوری: {self.game_state.technology_level}")
ConsoleUI.display_message(f"نفوذ دینی: {self.game_state.religious_influence}%")
# ذخیره نتیجه بازی
self.save_manager.save_game_result(self.game_state, f"شکست: {defeat_type}")
ConsoleUI.wait_for_enter()
self.running = False
def undo_last_action(self):
"""بازگرداندن آخرین اقدام"""
if not self.undo_stack:
ConsoleUI.display_warning("هیچ اقدامی برای بازگرداندن وجود ندارد.")
time.sleep(1)
return
# ذخیره وضعیت فعلی برای redo
self.redo_stack.append(self.game_state.copy())
# بازگرداندن آخرین وضعیت
self.game_state = self.undo_stack.pop()
ConsoleUI.display_success("آخرین اقدام با موفقیت بازگردانده شد.")
time.sleep(1)
def save_state_for_undo(self):
"""ذخیره وضعیت فعلی برای امکان undo"""
if len(self.undo_stack) >= GAME_CONFIG["max_undo_steps"]:
self.undo_stack.pop(0) # حذف قدیمیترین وضعیت
self.undo_stack.append(self.game_state.copy())
self.redo_stack = [] # پاک کردن redo stack
def show_tutorial(self):
"""نمایش راهنمای اولیه بازی"""
if ConsoleUI.confirm_action("آیا میخواهید راهنمای اولیه بازی را ببینید؟"):
ConsoleUI.clear_screen()
ConsoleUI.display_section_title("راهنمای اولیه بازی")
tutorial_steps = [
"در این بازی شما رهبر یک کشور تاریخی هستید که باید با تصمیمات استراتژیک، کشور خود را گسترش دهید.",
"در هر سال میتوانید اقدامات مختلفی انجام دهید: مدیریت اقتصاد، دیپلماسی، نظامی، و...",
"توجه به تعادل بین ثبات سیاسی، نارضایتی عمومی و منابع مالی بسیار مهم است.",
"رویدادهای تصادفی و تاریخی در طول بازی رخ خواهند داد که باید به آنها پاسخ دهید.",
"هدف نهایی شما رسیدن به یکی از شرایط پیروزی است: تسلط جهانی، اقتصادی، فرهنگی یا فناوری."
]
for step in tutorial_steps:
ConsoleUI.typewriter_effect(step)
time.sleep(0.5)
print()
ConsoleUI.wait_for_enter() |