Review Board 1.7.16


Mothership cmenuselect easteregg addition

Review Request #1555 - Created Nov. 1, 2011 and submitted

Jonathan Rose
menuselect
ASTERISK-18801
Reviewers
asterisk-dev
jrose
Menuselect
Adds a mothership bonus target to cmenuselect.  This target appears intermittently after killing a number of aliens, and will award bonus if shot.

Submitted by proxy for John Gould
Made sure motherships could be shot, made sure it didn't make the game unwinnable or win too soon.

Diff revision 1 (Latest)

  1. /trunk/menuselect_curses.c: Loading...
/trunk/menuselect_curses.c
Revision 953 New Change
[20] 562 lines
[+20] [+] int run_menu(void)
563

    
   
563

   
564
enum blip_type {
564
enum blip_type {
565
	BLIP_TANK = 0,
565
	BLIP_TANK = 0,
566
	BLIP_SHOT,
566
	BLIP_SHOT,
567
	BLIP_BOMB,
567
	BLIP_BOMB,
568
	BLIP_ALIEN
568
	BLIP_ALIEN,

    
   
569
	BLIP_UFO
569
};
570
};
570

    
   
571

   
571
struct blip {
572
struct blip {
572
	enum blip_type type;
573
	enum blip_type type;
573
	int x;
574
	int x;
[+20] [20] 4 lines
[+20] struct blip {
578
	AST_LIST_ENTRY(blip) entry;
579
	AST_LIST_ENTRY(blip) entry;
579
};
580
};
580

    
   
581

   
581
static AST_LIST_HEAD_NOLOCK(, blip) blips;
582
static AST_LIST_HEAD_NOLOCK(, blip) blips;
582

    
   
583

   

    
   
584
static int respawn = 0;
583
static int score = 0;
585
static int score = 0;
584
static int num_aliens = 0;
586
static int num_aliens = 0;
585
static int alien_sleeptime = 0;
587
static int alien_sleeptime = 0;

    
   
588
struct blip *ufo = NULL;
586
struct blip *tank = NULL;
589
struct blip *tank = NULL;
587

    
   
590

   
588
/*! Probability of a bomb, out of 100 */
591
/*! Probability of a bomb, out of 100 */
589
#define BOMB_PROB   1
592
#define BOMB_PROB   1
590

    
   
593

   
[+20] [20] 21 lines
[+20] [+] static int init_blips(void)
612
			cur = calloc(1, sizeof(struct blip));
615
			cur = calloc(1, sizeof(struct blip));
613
			if (!cur)
616
			if (!cur)
614
				return -1;
617
				return -1;
615
			cur->type = BLIP_ALIEN;
618
			cur->type = BLIP_ALIEN;
616
			cur->x = (j * 2) + 1;
619
			cur->x = (j * 2) + 1;
617
			cur->y = (i * 2) + 1;
620
			cur->y = (i * 2) + 2;
618
			AST_LIST_INSERT_HEAD(&blips, cur, entry);
621
			AST_LIST_INSERT_HEAD(&blips, cur, entry);
619
			num_aliens++;
622
			num_aliens++;
620
		}
623
		}
621
	}
624
	}
622

    
   
625

   
[+20] [20] 9 lines
[+20] [+] static inline chtype type2chtype(enum blip_type type)
632
		return 'X';
635
		return 'X';
633
	case BLIP_SHOT:
636
	case BLIP_SHOT:
634
		return '|';
637
		return '|';
635
	case BLIP_BOMB:
638
	case BLIP_BOMB:
636
		return 'o';
639
		return 'o';

    
   
640
	case BLIP_UFO:

    
   
641
		return '@';
637
	default:
642
	default:
638
		break;
643
		break;
639
	}
644
	}
640
	return '?';
645
	return '?';
641
}
646
}
[+20] [20] 151 lines
[+20] [+] static int remove_blip(struct blip *blip)
793
	free(blip);
798
	free(blip);
794

    
   
799

   
795
	return 0;	
800
	return 0;	
796
}
801
}
797

    
   
802

   

    
   
803
static int ufo_action()

    
   
804
{

    
   
805
	struct blip *cur;

    
   
806

   

    
   
807

   

    
   
808
	AST_LIST_TRAVERSE(&blips, cur, entry) {

    
   
809
		if (cur->type != BLIP_UFO) {

    
   
810
			continue;

    
   
811
		}

    
   
812

   

    
   
813
		cur->x--;

    
   
814

   

    
   
815
		if (cur->x < 0) {

    
   
816
			remove_blip(cur);

    
   
817
			respawn += 1;

    
   
818
		}

    
   
819

   

    
   
820
	}

    
   
821

   

    
   
822
	if (respawn == 7) {

    
   
823
		respawn = 0;

    
   
824
		/* make new mothership*/

    
   
825
		cur = calloc(1, sizeof(struct blip));

    
   
826
		if(!cur)

    
   
827
			return -1;

    
   
828
		cur->type = BLIP_UFO;

    
   
829
		cur->x = max_x - 1;

    
   
830
		cur->y = 1;

    
   
831
		AST_LIST_INSERT_HEAD(&blips, cur, entry);

    
   
832
	}

    
   
833

   

    
   
834
	return 0;

    
   
835
}

    
   
836

   

    
   
837

   
798
static void game_over(int win)
838
static void game_over(int win)
799
{
839
{
800
	clear();
840
	clear();
801

    
   
841

   
802
	wmove(stdscr, max_y / 2, max_x / 2 - 10);
842
	wmove(stdscr, max_y / 2, max_x / 2 - 10);
[+20] [20] 13 lines
[+20] static void game_over(int win)
816
static int check_shot(struct blip *shot)
856
static int check_shot(struct blip *shot)
817
{
857
{
818
	struct blip *cur;
858
	struct blip *cur;
819
	
859
	
820
	AST_LIST_TRAVERSE(&blips, cur, entry) {
860
	AST_LIST_TRAVERSE(&blips, cur, entry) {
821
		if (cur->type != BLIP_ALIEN)
861
		if (cur->type != BLIP_ALIEN && cur->type != BLIP_UFO)
822
			continue;
862
			continue;
823
		if (cur->x == shot->x && cur->y == shot->y) {
863
		if (cur->x == shot->x && cur->y == shot->y) {

    
   
864
			if (cur->type == BLIP_UFO) {

    
   
865
				score += 80;

    
   
866
			}
824
			score += 20;
867
			score += 20;
825
			remove_blip(shot);
868
			remove_blip(shot);
826
			remove_blip(cur);
869
			remove_blip(cur);

    
   
870
			respawn += 1;
827
			if (!num_aliens) {
871
			if (!num_aliens) {
828
				if(alien_sleeptime < 101) {
872
				if(alien_sleeptime < 101) {
829
					game_over(1);
873
					game_over(1);
830
					return 1;
874
					return 1;
831
				} else {
875
				} else {
[+20] [20] 64 lines
[+20] [+] static void play_space(void)
896
			if (quit) {
940
			if (quit) {
897
				alien_sleeptime = 1;
941
				alien_sleeptime = 1;
898
				break;
942
				break;
899
			}
943
			}
900
			if (!(jiffies % 25)) {
944
			if (!(jiffies % 25)) {
901
				if (move_aliens() || move_bombs()) {
945
				if (move_aliens() || move_bombs() || ufo_action()) {
902
					alien_sleeptime = 1;
946
					alien_sleeptime = 1;
903
					game_over(0);
947
					game_over(0);
904
					break;
948
					break;
905
				}
949
				}
906
				if (check_placement())
950
				if (check_placement())
[+20] [20] 18 lines
  1. /trunk/menuselect_curses.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.