forked from kastian/dictator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnews.c
38 lines (34 loc) · 1.1 KB
/
news.c
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
/*
Display news and apply their consequencies
Copyright (C) 1983 Don Priestley - original zx-basic code.
Copyright (C) 1983 DkTRONICS - original zx-basic code.
2015 #kstn - port to C.
*/
#include "news.h"
void news()
{
if (rand()%3) /* Try to get news (chances 1/3) */
return;
int a; /* For cycle */
int r = rand() % NEWS_SIZE; /* Define random news */
for (a = 0; a < NEWS_SIZE; a++)
{
if (! NEWS[r].used) /* Take news if it is unused */
break;
r++; /* Or try next */
if (r == NEWS_SIZE) /* If it is the last news in list */
r = 0; /* then start from the beginning */
if (a == NEWS_SIZE - 1) /* If there are no unused news */
return;
}
erase();
mvprintw(1, 24, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
mvprintw(3, 35, "NEWSFLASH\n");
attron(A_BOLD);
mvprintw(12, 24, "%s\n", NEWS[r].text);
attroff(A_BOLD);
key();
transfer(&NEWS[r]); /* Apply news consequences */
plot(); /* Recount chances to assasination/revolution */
police_report(); /* And look at results */
}