-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprinter.h
92 lines (83 loc) · 1.92 KB
/
printer.h
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
//
// Created by 20281 on 2022/9/12.
//
#ifndef C__LEARN_PRINTER_H
#define C__LEARN_PRINTER_H
#include <windows.h>
#include <iomanip>
#include "Player.h"
/**
* 设置控制台打印的颜色
* @param a 颜色值
*/
void setColor(int a) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
/**
* 打印生物的信息
* @param biology 通常是玩家
*/
void printBiologyData(const Player &biology) {
// 红色血量
setColor(4);
cout << "血:";
for (int i = 0; i < (int) (biology.hp.value); i++) {
cout << "Δ";
}
cout << endl;
// 鸡腿
setColor(6);
cout << "饱:";
for (int i = 0; i < (int) (biology.hunger.value); i++) {
cout << "●";
}
cout << endl;
// 气
if (biology.state == inWater) {
setColor(11);
cout << "气:";
for (int i = 0; i < (int) (biology.breath.value); i++) {
cout << "◎";
}
}
setColor(7);
cout << endl;
// 物品栏
cout << "1 2 3 4 5 6 7 8 9 0 " << endl;
for (GameObject o: biology.item) {
setColor(o);
cout << objectToStr[o];
}
setColor(7);
cout << endl;
for (int i = 0; i < biology.itemIndex; i++) {
cout << " ";
}
cout << "↑" << endl;
// 背包
cout << "packet: {";
for (auto [k, v]: biology.pack) {
setColor(k);
cout << objectToStr[k];
setColor(7);
cout << ":" << v << ", ";
}
cout << "}" << endl;
// 手动合成台
if (!biology.availableList.empty()) {
cout << "可合成:" << endl;
for (GameObject newObj: biology.availableList) {
setColor(newObj);
cout << objectToStr[newObj];
}
setColor(7);
cout << endl;
for (int i = 0; i < biology.availableIndex; i++) {
cout << " ";
}
cout << "↑" << endl;
} else {
cout << "当前没有可以合成的物品" << endl;
}
}
#endif //C__LEARN_PRINTER_H