-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowcase.py
More file actions
executable file
·149 lines (125 loc) · 5.32 KB
/
showcase.py
File metadata and controls
executable file
·149 lines (125 loc) · 5.32 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
完整游戏演示 - 展示一个完整的人生旅程
"""
from life_simulator import LifeSimulator
from events import GameState
import random
def showcase_game():
"""展示完整的游戏功能"""
print("=" * 70)
print(" " * 20 + "人生模拟器完整演示")
print("=" * 70)
print()
print("这是一个完全由概率驱动的人生模拟游戏。")
print("没有天赋选择,一切都由命运决定。")
print()
print("功能特点:")
print(" • 68+ 个事件分支,覆盖人生各个阶段")
print(" • 12 种不同结局")
print(" • 特殊灾难事件:丧尸爆发、人类消失、外星接触等")
print(" • 动态概率调整系统")
print(" • 以月为单位的时间推进")
print()
print("-" * 70)
print()
# 创建游戏
game = LifeSimulator()
# 显示角色生成
print("【角色生成】")
game._initialize_character()
print()
# 模拟游戏进程
print("【人生旅程开始】")
print()
important_events = []
last_display_age = -1
for i in range(1200): # 最多100年
# 推进时间
game.month += 1
if game.month > 12:
game.month = 1
game.year += 1
game.age = game.year
# 每5年或发生重要事件时显示状态
if game.age != last_display_age and (game.age % 10 == 0 or game.age < 5):
print(f"\n【{game.age}岁】")
print(f" 健康: {game.state.health:3.0f} | 财富: {game.state.wealth:7.0f} | 幸福: {game.state.happiness:3.0f}")
if game.state.current_phase:
print(f" 阶段: {game.state.current_phase}")
if game.state.world_state != 'normal':
print(f" 世界状态: {game.state.world_state}")
last_display_age = game.age
# 触发事件
event_result = game.event_manager.trigger_event(game.state, game.age, game.month)
if event_result:
# 记录重要事件
event_title = event_result.split('\n')[0].strip('【】')
# 判断是否为重要事件
important_keywords = [
'结婚', '生育', '升职', '失业', '大学', '工作', '退休',
'丧尸', '消失', '外星', '穿越', '中奖', '英雄', '病',
'去世', '离世', '咬伤', '疫苗', '康复', '创业'
]
is_important = any(keyword in event_result for keyword in important_keywords)
if is_important:
important_events.append((game.age, event_title))
print(f"\n ⭐ {event_title}")
# 如果是特别重要的事件,显示更多细节
if any(kw in event_result for kw in ['丧尸', '消失', '外星', '中奖', '死亡', '咬伤']):
lines = event_result.split('\n')
if len(lines) > 1:
print(f" {lines[1][:60]}...")
# 检查游戏结束
if game.state.is_dead:
print(f"\n\n【游戏结束 - 死亡】")
print(f" 享年: {game.age}岁")
print(f" 死因: {game.state.death_reason}")
print(f" 最终财富: {game.state.wealth:.0f}")
print(f" 最终幸福: {game.state.happiness:.0f}")
break
ending = game.ending_manager.check_ending(game.state, game.age)
if ending:
print(f"\n\n【游戏结束 - 达成结局】")
print(f" 结局: {ending['title']}")
print(f" 年龄: {game.age}岁")
print(f" 最终健康: {game.state.health:.0f}")
print(f" 最终财富: {game.state.wealth:.0f}")
print(f" 最终幸福: {game.state.happiness:.0f}")
print()
print(f" 结局描述:")
desc_lines = ending['description'].split('\n\n')
for line in desc_lines[:2]: # 只显示前两段
print(f" {line}")
break
# 总结
print()
print("-" * 70)
print("【人生总结】")
print(f" 总共经历: {game.age}年{game.month}月")
print(f" 触发事件: {len(game.state.triggered_events)}个")
print(f" 重要事件: {len(important_events)}个")
if important_events:
print("\n 重要事件列表:")
for age, event in important_events[:15]: # 只显示前15个
print(f" • {age}岁 - {event}")
if len(important_events) > 15:
print(f" ... 还有{len(important_events) - 15}个事件")
# 显示统计
print()
print("【数据统计】")
print(f" 最终健康: {game.state.health:.0f}/100")
print(f" 最终财富: {game.state.wealth:.0f}")
print(f" 最终幸福: {game.state.happiness:.0f}/100")
if game.state.special_status:
print(f" 特殊状态: {', '.join(game.state.special_status)}")
print()
print("=" * 70)
print("演示结束!感谢观看!")
print()
print("运行 'python life_simulator.py' 开始你自己的人生旅程!")
print("=" * 70)
if __name__ == "__main__":
random.seed(42) # 设置随机种子以获得可重复的演示
showcase_game()