• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Xevion / Pac-Man / 16902905385

12 Aug 2025 08:07AM UTC coverage: 45.41% (-0.5%) from 45.95%
16902905385

Pull #1

github

web-flow
chore(deps): bump actions/checkout from 4 to 5 in the dependencies group

Bumps the dependencies group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 4 to 5
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1: chore(deps): bump actions/checkout from 4 to 5 in the dependencies group

737 of 1623 relevant lines covered (45.41%)

297.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.92
/src/map/parser.rs
1
//! Map parsing functionality for converting raw board layouts into structured data.
2

3
use crate::constants::{MapTile, BOARD_CELL_SIZE};
4
use glam::IVec2;
5
use thiserror::Error;
6

7
/// Error type for map parsing operations.
8
#[derive(Debug, Error)]
9
pub enum ParseError {
10
    #[error("Unknown character in board: {0}")]
11
    UnknownCharacter(char),
12
    #[error("House door must have exactly 2 positions, found {0}")]
13
    InvalidHouseDoorCount(usize),
14
}
15

16
/// Represents the parsed data from a raw board layout.
17
#[derive(Debug)]
18
pub struct ParsedMap {
19
    /// The parsed tile layout.
20
    pub tiles: [[MapTile; BOARD_CELL_SIZE.y as usize]; BOARD_CELL_SIZE.x as usize],
21
    /// The positions of the house door tiles.
22
    pub house_door: [Option<IVec2>; 2],
23
    /// The positions of the tunnel end tiles.
24
    pub tunnel_ends: [Option<IVec2>; 2],
25
    /// Pac-Man's starting position.
26
    pub pacman_start: Option<IVec2>,
27
}
28

29
/// Parser for converting raw board layouts into structured map data.
30
pub struct MapTileParser;
31

32
impl MapTileParser {
33
    /// Parses a single character into a map tile.
34
    ///
35
    /// # Arguments
36
    ///
37
    /// * `c` - The character to parse
38
    ///
39
    /// # Returns
40
    ///
41
    /// The parsed map tile, or an error if the character is unknown.
42
    pub fn parse_character(c: char) -> Result<MapTile, ParseError> {
5,244✔
43
        match c {
5,244✔
44
            '#' => Ok(MapTile::Wall),
3,076✔
45
            '.' => Ok(MapTile::Pellet),
1,441✔
46
            'o' => Ok(MapTile::PowerPellet),
25✔
47
            ' ' => Ok(MapTile::Empty),
667✔
48
            'T' => Ok(MapTile::Tunnel),
13✔
49
            'X' => Ok(MapTile::Empty), // Pac-Man's starting position, treated as empty
7✔
50
            '=' => Ok(MapTile::Wall),  // House door is represented as a wall tile
13✔
51
            _ => Err(ParseError::UnknownCharacter(c)),
2✔
52
        }
53
    }
5,244✔
54

55
    /// Parses a raw board layout into structured map data.
56
    ///
57
    /// # Arguments
58
    ///
59
    /// * `raw_board` - The raw board layout as an array of strings
60
    ///
61
    /// # Returns
62
    ///
63
    /// The parsed map data, or an error if parsing fails.
64
    ///
65
    /// # Errors
66
    ///
67
    /// Returns an error if the board contains unknown characters or if the house door
68
    /// is not properly defined by exactly two '=' characters.
69
    pub fn parse_board(raw_board: [&str; BOARD_CELL_SIZE.y as usize]) -> Result<ParsedMap, ParseError> {
7✔
70
        let mut tiles = [[MapTile::Empty; BOARD_CELL_SIZE.y as usize]; BOARD_CELL_SIZE.x as usize];
7✔
71
        let mut house_door = [None; 2];
7✔
72
        let mut tunnel_ends = [None; 2];
7✔
73
        let mut pacman_start: Option<IVec2> = None;
7✔
74

75
        for (y, line) in raw_board.iter().enumerate().take(BOARD_CELL_SIZE.y as usize) {
187✔
76
            for (x, character) in line.chars().enumerate().take(BOARD_CELL_SIZE.x as usize) {
5,236✔
77
                let tile = Self::parse_character(character)?;
5,236✔
78

79
                // Track special positions
80
                match tile {
3,087✔
81
                    MapTile::Tunnel => {
82
                        if tunnel_ends[0].is_none() {
12✔
83
                            tunnel_ends[0] = Some(IVec2::new(x as i32, y as i32));
6✔
84
                        } else {
6✔
85
                            tunnel_ends[1] = Some(IVec2::new(x as i32, y as i32));
6✔
86
                        }
6✔
87
                    }
88
                    MapTile::Wall if character == '=' => {
3,087✔
89
                        if house_door[0].is_none() {
12✔
90
                            house_door[0] = Some(IVec2::new(x as i32, y as i32));
6✔
91
                        } else {
6✔
92
                            house_door[1] = Some(IVec2::new(x as i32, y as i32));
6✔
93
                        }
6✔
94
                    }
95
                    _ => {}
5,211✔
96
                }
97

98
                // Track Pac-Man's starting position
99
                if character == 'X' {
5,235✔
100
                    pacman_start = Some(IVec2::new(x as i32, y as i32));
6✔
101
                }
5,229✔
102

103
                tiles[x][y] = tile;
5,235✔
104
            }
105
        }
106

107
        // Validate house door configuration
108
        let house_door_count = house_door.iter().filter(|x| x.is_some()).count();
12✔
109
        if house_door_count != 2 {
6✔
110
            return Err(ParseError::InvalidHouseDoorCount(house_door_count));
×
111
        }
6✔
112

6✔
113
        Ok(ParsedMap {
6✔
114
            tiles,
6✔
115
            house_door,
6✔
116
            tunnel_ends,
6✔
117
            pacman_start,
6✔
118
        })
6✔
119
    }
7✔
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc