-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
96 lines (79 loc) · 2.01 KB
/
Source.cpp
File metadata and controls
96 lines (79 loc) · 2.01 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
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#pragma warning(disable:4996)
//パラメータの構造体
struct tag_Attributes
{
int strength;
int constitution;
int dexterity;
int speed;
int luck;
int intelligence;
int wizardry;
int charisma;
};
typedef struct tag_Attributes Attributes;
struct tag_Character
{
char name[21];
char kindred[21];
Attributes attributes;
};
typedef struct tag_Character Character;
Character CreateCharacter(char* a, char* b);
void PrintCharacterSheet(const Character* player);
int roll_dice(void);
int main(void)
{
srand((unsigned int)time(NULL));
char a[21];
char b[21];
scanf("%s", a);
scanf("%s", b);
printf("\n");
Character player = CreateCharacter(a, b);
PrintCharacterSheet(&player);
return 0;
}
Character CreateCharacter(char* a, char* b)
{
Character player;
strcpy(player.name, a);
strcpy(player.kindred, b);
player.attributes.strength = roll_dice();
player.attributes.constitution = roll_dice();
player.attributes.dexterity = roll_dice();
player.attributes.speed = roll_dice();
player.attributes.luck = roll_dice();
player.attributes.intelligence = roll_dice();
player.attributes.wizardry = roll_dice();
player.attributes.charisma = roll_dice();
return player;
}
void PrintCharacterSheet(const Character* player)
{
printf("名前:%s\n", player->name);
printf("種族:%s\n", player->kindred);
printf("体力度:%d\n", player->attributes.strength);
printf("耐久度:%d\n", player->attributes.constitution);
printf("器用度:%d\n", player->attributes.dexterity);
printf("速度:%d\n", player->attributes.speed);
printf("幸運度:%d\n", player->attributes.luck);
printf("知性度:%d\n", player->attributes.intelligence);
printf("魔力度:%d\n", player->attributes.wizardry);
printf("魅力度:%d\n", player->attributes.charisma);
}
int roll_dice(void)
{
int number, sum, i;
sum = 0;
for (i = 0; i < 3; i++)
{
number = rand() % 6 + 1;
sum += number;
}
return sum;
}