Function calculateScore Responsible for calculating the score obtained during the game.
443{
444 int c = 0, b = 0, e = 0, d = 0;
445
446 if (mat[line][column] == 10)
447 {
448 mat[line][column] = 50;
449 return 2;
450 }
451
452 else if (mat[line][column] == 20)
453 {
454 if (mat[line + 1][column] == 20)
455 {
456 b = 1;
457 }
458
459 if (mat[line - 1][column] == 20)
460 {
461 c = 1;
462 }
463
464 if (mat[line][column + 1] == 20)
465 {
466 d = 1;
467 }
468
469 if (mat[line][column - 1] == 20)
470 {
471 e = 1;
472 }
473
474 if (b == 1)
475 {
476 if (mat[line + 1][column] == 20)
477 {
478 mat[line][column] = 50;
479 mat[line + 1][column] = 50;
480 return 4;
481 }
482 else
483 {
484 return 0;
485 }
486 }
487
488 if (c == 1)
489 {
490 if (mat[line - 1][column] == 20)
491 {
492 mat[line][column] = 50;
493 mat[line - 1][column] = 50;
494 return 4;
495 }
496 else
497 {
498 return 0;
499 }
500 }
501
502 if (d == 1)
503 {
504 if (mat[line][column + 1] == 20)
505 {
506 mat[line][column] = 50;
507 mat[line][column + 1] = 50;
508 return 4;
509 }
510 else
511 {
512 return 0;
513 }
514 }
515
516 if (e == 1)
517 {
518 if (mat[line][column - 1] == 20)
519 {
520 mat[line][column] = 50;
521 mat[line][column - 1] = 50;
522 return 4;
523 }
524 else
525 {
526 return 0;
527 }
528 }
529 }
530
531 else if (mat[line][column] == 30)
532 {
533 if (mat[line + 1][column] == 30)
534 {
535 b = 1;
536 }
537
538 if (mat[line - 1][column] == 30)
539 {
540 c = 1;
541 }
542 if (mat[line][column + 1] == 30)
543 {
544 d = 1;
545 }
546
547 if (mat[line][column - 1] == 30)
548 {
549 e = 1;
550 }
551
552 if (b == 1 && c == 1)
553 {
554 if (mat[line + 1][column] == 30 && mat[line - 1][column] == 30)
555 {
556 mat[line][column] = 50;
557 mat[line + 1][column] = 50;
558 mat[line - 1][column] = 50;
559 return 7;
560 }
561 else
562 {
563 return 0;
564 }
565 }
566
567 else if (d == 1 && e == 1)
568 {
569 if (mat[line][column + 1] == 30 && mat[line][column - 1] == 30)
570 {
571 mat[line][column] = 50;
572 mat[line][column - 1] = 50;
573 mat[line][column + 1] = 50;
574 return 7;
575 }
576 else
577 {
578 return 0;
579 }
580 }
581
582 else if (d == 1)
583 {
584 if (mat[line][column + 1] == 30 && mat[line][column + 2] == 30)
585 {
586 mat[line][column] = 50;
587 mat[line][column + 1] = 50;
588 mat[line][column + 2] = 50;
589 return 7;
590 }
591 else
592 {
593 return 0;
594 }
595 }
596
597 else if (e == 1)
598 {
599 if (mat[line][column - 1] == 30 && mat[line][column - 2] == 30)
600 {
601 mat[line][column] = 50;
602 mat[line][column - 1] = 50;
603 mat[line][column - 2] = 50;
604 return 7;
605 }
606 else
607 {
608 return 0;
609 }
610 }
611
612 else if (c == 1)
613 {
614 if (mat[line - 1][column] == 30 && mat[line - 2][column] == 30)
615 {
616 mat[line][column] = 50;
617 mat[line - 1][column] = 50;
618 mat[line - 2][column] = 50;
619 return 7;
620 }
621 else
622 {
623 return 0;
624 }
625 }
626
627 else if (b == 1)
628 {
629 if (mat[line + 1][column] == 30 && mat[line + 2][column] == 30)
630 {
631 mat[line][column] = 50;
632 mat[line + 1][column] = 50;
633 mat[line + 2][column] = 50;
634 return 7;
635 }
636 else
637 {
638 return 0;
639 }
640 }
641 }
642 return 0;
643}