-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.h
105 lines (94 loc) · 2.72 KB
/
controller.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
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
#include <ncurses.h>
#include <stdlib.h>
#include "views.h"
#include "model.h"
void createController(Character* character) {
clear();
setupView();
char buffer[16];
char *endptr;
printw("Enter STR score\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
long val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 0 || val > 20) {
printw("Invalid input, setting STR to 10. This can be changed later\n\n");
character->STR = 10;
}
else {
character->STR = (int)val;
}
printw("Enter DEX score\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 0 || val > 20) {
printw("Invalid input, setting DEX to 10. This can be changed later\n\n");
character->DEX = 10;
}
else {
character->DEX = (int)val;
}
printw("Enter CON score\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 0 || val > 20) {
printw("Invalid input, setting CON to 10. This can be changed later\n\n");
character->CON = 10;
}
else {
character->CON = (int)val;
}
printw("Enter INT score\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 0 || val > 20) {
printw("Invalid input, setting INT to 10. This can be changed later\n\n");
character->INT = 10;
}
else {
character->INT = (int)val;
}
printw("Enter WIS score\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 0 || val > 20) {
printw("Invalid input, setting WIS to 10. This can be changed later\n\n");
character->WIS = 10;
}
else {
character->WIS = (int)val;
}
printw("Enter CHA score\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 0 || val > 20) {
printw("Invalid input, setting CHA to 10. This can be changed later\n\n");
character->CHA = 10;
}
else {
character->CHA = (int)val;
}
printw("\nEnter Proficiency Bonus\n");
printw(">> ");
getnstr(buffer, sizeof(buffer));
val = strtol(buffer, &endptr, 10);
if(endptr == buffer || val < 2 || val > 6) {
printw("Invalid input, setting Proficiency Bonus to 2. This can be changed later\n\n");
character->proficiency = 2;
}
else {
character->proficiency = (int)val;
}
getch();
}
void loadController() {
clear();
printw("load\n");
getch();
}