Пример #1
0
int main(int argc, char *argv[])
{
    char* line = NULL;
    size_t len = 0;
    ssize_t read;

    char action[8];
    int lights[1000][1000];
    int from[2] = {0, 0};
    int to[2] = {0, 0};

    init(lights);

    while ((read = getline(&line, &len, stdin)) != -1) {
        sscanf(line, "%[ togleurnf] %d,%d through %d,%d", action, &from[0], &from[1], &to[0], &to[1]);

        if (strcmp(action, "turn on ") == 0) {
            turn_on(lights, from, to);
        } else if (strcmp(action, "turn off ") == 0) {
            turn_off(lights, from, to);
        } else if (strcmp(action, "toggle ") == 0) {
            toggle(lights, from, to);
        } else {
            puts("bad action");
            return 1;
        }

    }

    printf("%d\n", count(lights));

    return 0;
}
Пример #2
0
void
electrificate(void)
{
    int affect_dist = 4 + player.t_stats.s_lvl / 4;
    struct linked_list  *item, *nitem;

    for (item = mlist; item != NULL; item = nitem)
    {
        struct thing *tp = THINGPTR(item);
        char *mname = monsters[tp->t_index].m_name;

        nitem = next(item);

        if (DISTANCE(tp->t_pos, hero) < affect_dist)
        {
            int damage = roll(2, player.t_stats.s_lvl);

            debug("Charge does %d (%d)", damage, tp->t_stats.s_hpt - damage);

            if (on(*tp, NOBOLT))
                continue;

            if ((tp->t_stats.s_hpt -= damage) <= 0)
            {
                msg("The %s is killed by an electric shock.", mname);
                killed(&player, item, NOMESSAGE, POINTS);
                continue;
            }

            if (rnd(tp->t_stats.s_intel / 5) == 0)
            {
                turn_on(*tp, ISFLEE);
                msg("The %s is shocked by electricity.", mname);
            }
            else
                msg("The %s is zapped by your electricity.", mname);

            summon_help(tp, NOFORCE);
            turn_off(*tp, ISFRIENDLY);
            turn_off(*tp, ISCHARMED);
            turn_on(*tp, ISRUN);
            turn_off(*tp, ISDISGUISE);
            chase_it(&tp->t_pos, &player);
            fighting = after = running = FALSE;
        }
    }
}
Пример #3
0
fuse
scent(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISUNSMELL);
    msg("You begin to smell the damp dungeon air again.");
}
Пример #4
0
fuse
unscent(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, CANSCENT);
    msg("The smell of monsters goes away.");
}
Пример #5
0
fuse
unsupereat(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, SUPEREAT);
    msg("You stop feeling so hungry.");
}
/*
 * shero:
 *	restore lost abilities from cursed potion of shero
 */
void
shero(void)
{
    msg("You feel normal again.");
    chg_str(2, FALSE, TRUE);
    chg_dext(2, FALSE, TRUE);
    turn_off(player, ISUNHERO);
}
/*
 * undisguise:
 *	player stops looking like a monster
 */
void
undisguise(void)
{
    msg("Your skin feels itchy for a moment.");
    turn_off(player, ISDISGUISE);
    PLAYER = VPLAYER;
    light(&hero);
}
/*
 * unbhero:
 *	super heroism wears off, but no bad effects
 */
void
unbhero(void)
{
    msg("Your feeling of invincibility goes away.");
    turn_off(player, SUPERHERO);
    chg_str(-10, FALSE, FALSE);
    chg_dext(-5, FALSE, FALSE);
}
/*
 * appear:
 *	Become visible again
 */
void
appear(void)
{
    turn_off(player, ISINVIS);
    PLAYER = VPLAYER;
    msg("The tingling feeling leaves your body.");
    light(&hero);
}
/*
 * daemon for curing the diseased
 */
void
cure_disease(void)
{
    turn_off(player, HASDISEASE);
    if (off (player, HASINFEST))
	msg(terse ? "You feel yourself improving."
		: "You begin to feel yourself improving again.");
}
/*
 * unphase:
 *	Player can no longer walk through walls
 */
void
unphase(void)
{
    turn_off(player, CANINWALL);
    msg("Your dizzy feeling leaves you.");
    if (!step_ok(hero.y, hero.x, NOMONST, &player)) 
	death(D_PETRIFY);
}
/*
 * unsee:
 *	He lost his see invisible power
 */
void
unsee(void)
{
    if (!ISWEARING(R_SEEINVIS)) {
	turn_off(player, CANSEE);
	msg("The tingling feeling leaves your eyes.");
    }
}
Пример #13
0
fuse
unhear(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, CANHEAR);
    msg("The sounds of monsters fades away.");
}
Пример #14
0
fuse
unmshield(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, HASMSHIELD);
    msg("The fog dissapates.");
}
Пример #15
0
fuse
hear(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISDEAF);
    msg("You can hear again.");
}
Пример #16
0
fuse
ungaze(fuse_arg *arg)
{
    NOOP(arg);

    msg("The shiny particles swirl to the floor.");
    turn_off(player, CANREFLECT);
}
Пример #17
0
fuse
noslow(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISSLOW);
    msg("You feel yourself speeding up.");
}
Пример #18
0
fuse
nohaste(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISHASTE);
    msg("You feel yourself slowing down.");
}
Пример #19
0
fuse
unclrhead(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISCLEAR);
    msg("The blue aura about your head fades away.");
}
Пример #20
0
fuse
unconfuse(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISHUH);
    msg("You feel less confused now.");
    return;
}
/*
 * daemon for adding back dexterity
 */
void
un_itch(void)
{
    if (lost_dext) {
	chg_dext(lost_dext, FALSE, FALSE);
	lost_dext = 0;
	turn_off(player, HASITCH);
    }
}
Пример #22
0
fuse
unelectrify(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISELECTRIC);
    msg("The sparks and violet glow from your body fade away.");
    light(&hero);
}
Пример #23
0
 void close ()
 {
   if (fd >= 0) {
     turn_off ();
     // close (fd);
     tcp_abort (fd);
     fd = -1;
   }
 }
Пример #24
0
nevil::object::object(int x, int y, double size_x, double size_y
  , double height, const Enki::Color &off_color, const Enki::Color &on_color)
  : _off_color(off_color)
  , _on_color(on_color)
{
  pos = Enki::Point(x, y);
  setRectangular(size_x, size_y, height, -1);
  turn_off();
}
Пример #25
0
static void gb_vibrator_worker(struct work_struct *work)
{
	struct delayed_work *delayed_work = to_delayed_work(work);
	struct gb_vibrator_device *vib =
		container_of(delayed_work,
			     struct gb_vibrator_device,
			     delayed_work);

	turn_off(vib);
}
Пример #26
0
fuse
unhot(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, NOFIRE);

    if (!is_wearing(R_FIRERESIST))
        msg("You feel a flush of warmth.");
}
Пример #27
0
fuse
unfly(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, CANFLY);

    if (!is_wearing(R_LEVITATION))
        msg("You float gently to the ground.");
}
Пример #28
0
fuse
unshield(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, HASSHIELD);
    pstats.s_arm -= pstats.s_acmod;
    pstats.s_acmod = 0;
    msg("Your skin feels normal.");
}
Пример #29
0
fuse
unbreathe(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, HASOXYGEN);

    if (!is_wearing(R_BREATHE))
        msg("You start huffing and puffing.");
}
Пример #30
0
fuse
unregen(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISREGEN);

    if (!is_wearing(R_REGEN))
        msg("Your metabolism slows down.");
}