dnd 5e – What happens when I redirect an attack with mounted combatant but I am outside the reach of their weapon on a grid?

The mounted combatant feat (PHB 168) allows someone to “force an attack targeted at your mount to target you instead.”

Suppose I am playing on a grid. Let E be enemies without reach/ranged weapons. M be the spaces a large mount occupies. And R be the space I occupy while riding the mount.

$begin{array}{|l|l|r|}
hline
text{E} & \
hline
text{E} & text{M} & text{R}\
hline
text{E} & text{M} & text{M} \
hline
end{array}
$

What happens when I redirect an attack with mounted combatant but I am outside the reach of their weapon on a grid?

Missing field in filter tab of grid

i have some problem with grid in backend.
[1]: https://i.stack.imgur.com/Oocnu.png

I dont see any field of filter @@ any idea to fix or debug! tks very much

magento2 – Magento 2 – Custom Grid Action 404 error Add Action Throws 404 Error

i Develop Simple Crude Operation Module That Throws 404

enter image description here

etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

    <preference for="VrinsoftAppscreensApiDataAllsectionInterface" type="VrinsoftAppscreensModelAllsection" />
    <preference for="VrinsoftAppscreensApiAllsectionRepositoryInterface" type="VrinsoftAppscreensModelAllsectionRepository" />

    <virtualType name="AllsectionGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">VrinsoftAppscreensModelResourceModelAllsectionCollection</argument>
        </arguments>
    </virtualType>
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="section_allsection_listing_data_source" xsi:type="string">VrinsoftAppscreensModelResourceModelAllsectionGridCollection</item>
            </argument>
        </arguments>
    </type>
    <type name="VrinsoftAppscreensModelResourceModelAllsectionGridCollection">
        <arguments>
            <argument name="mainTable" xsi:type="string">screen_layer_data</argument>
            <argument name="eventPrefix" xsi:type="string">section_allsection_collection</argument>
            <argument name="eventObject" xsi:type="string">allsection_collection</argument>
            <argument name="resourceModel" xsi:type="string">VrinsoftAppscreensModelResourceModelAllnews</argument>
        </arguments>
    </type>

    <preference for="VrinsoftAppscreensApiCustomInterface" type="VrinsoftAppscreensModelApiCustom"/>
    <preference for="VrinsoftAppscreensApiDataCustomInterface" type="VrinsoftAppscreensModelApiCustomData"/>

</config>

view/adminhtml/ui_component/section_allsection_listing.xml

<?xml version="1.0" encoding="UTF-8"?>

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">section_allsection_listing.section_allsection_listing_data_source</item>
            <item name="deps" xsi:type="string">section_allsection_listing.section_allsection_listing_data_source</item>
        </item>
        <item name="spinner" xsi:type="string">allsection_columns</item>
        <item name="buttons" xsi:type="array">
            <item name="add" xsi:type="array">
                <item name="name" xsi:type="string">add</item>
                <item name="label" xsi:type="string" translate="true">Add New Layer</item>
                <item name="class" xsi:type="string">primary</item>
                <item name="url" xsi:type="string">*/*/new</item>
            </item>
        </item>
    </argument>
    <dataSource name="section_allsection_listing_data_source">
        <argument name="dataProvider" xsi:type="configurableObject">
            <argument name="class" xsi:type="string">AllsectionGridDataProvider</argument>
            <argument name="name" xsi:type="string">section_allsection_listing_data_source</argument>
            <argument name="primaryFieldName" xsi:type="string">layer_id</argument>
            <argument name="requestFieldName" xsi:type="string">id</argument>
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
                    <item name="update_url" xsi:type="url" path="mui/index/render"/>
                    <item name="storageConfig" xsi:type="array">
                        <item name="indexField" xsi:type="string">layer_id</item>
                    </item>
                </item>
            </argument>
        </argument>
    </dataSource>
    <listingToolbar name="listing_top">
        <settings>
            <sticky type="xs:boolean">false</sticky>
        </settings>
        <bookmark name="bookmarks"/>
        <columnsControls name="columns_controls" />
        <filterSearch name="fulltext"/>
        <filters name="listing_filters">
            <argument name="data" xsi:type="array">
                <item name="observers" xsi:type="array">
                    <item name="column" xsi:type="string">column</item>
                </item>
            </argument>
            <settings>
                <templates>
                    <filters>
                        <select>
                            <param name="template" xsi:type="string">ui/grid/filters/elements/ui-select</param>
                            <param name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</param>
                        </select>
                    </filters>
                </templates>
            </settings>
        </filters>
        <massaction name="listing_massaction">
            <action name="delete">
                <settings>
                    <confirm>
                        <message translate="true">Are you sure you want to delete selected items?</message>
                        <title translate="true">Delete items</title>
                    </confirm>
                    <url path="section/allsection/massDelete"/>
                    <type>delete</type>
                    <label translate="true">Delete</label>
                </settings>
            </action>
        </massaction>
        <paging name="listing_paging"/>
    </listingToolbar>
    <columns name="allsection_columns">
        <settings>
            <editorConfig>
                <param name="clientConfig" xsi:type="array">
                    <item name="saveUrl" xsi:type="url" path="section/allsection/inlineEdit"/>
                    <item name="validateBeforeSave" xsi:type="boolean">false</item>
                </param>
                <param name="indexField" xsi:type="string">layer_id</param>
                <param name="enabled" xsi:type="boolean">true</param>
                <param name="selectProvider" xsi:type="string">section_allsection_listing.section_allsection_listing.allsection_columns.ids</param>
            </editorConfig>
            <childDefaults>
                <param name="fieldAction" xsi:type="array">
                    <item name="provider" xsi:type="string">section_allsection_listing.section_allsection_listing.allsection_columns_editor</item>
                    <item name="target" xsi:type="string">startEdit</item>
                    <item name="params" xsi:type="array">
                        <item name="0" xsi:type="string">${ $.$data.rowIndex }</item>
                        <item name="1" xsi:type="boolean">true</item>
                    </item>
                </param>
            </childDefaults>
        </settings>
        <selectionsColumn name="ids">
            <settings>
                <indexField>layer_id</indexField>
                <resizeEnabled>false</resizeEnabled>
                <resizeDefaultWidth>55</resizeDefaultWidth>
            </settings>
        </selectionsColumn>

        <column name="layer_id">
            <settings>
                <filter>textRange</filter>
                <label translate="true">ID</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="category_name">
            <settings>
                <filter>category_name</filter>
                <editor>
                    <validation>
                        <rule name="required-entry" xsi:type="boolean">true</rule>
                    </validation>
                    <editorType>category_name</editorType>
                </editor>
                <label translate="true">Category Name</label>
            </settings>
        </column>
        <column name="layer_name">
            <settings>
                <filter>layer_name</filter>
                <editor>
                    <validation>
                        <rule name="required-entry" xsi:type="boolean">true</rule>
                    </validation>
                    <editorType>layer_name</editorType>
                </editor>
                <label translate="true">Layer Name</label>
            </settings>
        </column>


        <column name="status" component="Magento_Ui/js/grid/columns/select">
            <settings>
                <options class="VrinsoftAppscreensModelAllsectionSourceStatus"/>
                <filter>select</filter>
                <editor>
                    <editorType>select</editorType>
                </editor>
                <dataType>select</dataType>
                <label translate="true">Status</label>
            </settings>
        </column>
        <column name="created_at" class="MagentoUiComponentListingColumnsDate" component="Magento_Ui/js/grid/columns/date">
            <settings>
                <filter>dateRange</filter>
                <dataType>date</dataType>
                <label translate="true">Created</label>
            </settings>
        </column>
        <column name="updated_at" class="MagentoUiComponentListingColumnsDate" component="Magento_Ui/js/grid/columns/date">
            <settings>
                <filter>dateRange</filter>
                <dataType>date</dataType>
                <label translate="true">Modified</label>
            </settings>
        </column>
        <actionsColumn name="actions" class="VrinsoftAppscreensUiComponentListingColumnAllsectionActions">
            <settings>
                <indexField>layer_id</indexField>
                <resizeEnabled>false</resizeEnabled>
                <resizeDefaultWidth>107</resizeDefaultWidth>
            </settings>
        </actionsColumn>
    </columns>
</listing>

Ui/Component/Listing/Column/AllsectionActions.php

<?php

namespace VrinsoftAppscreensUiComponentListingColumn;

use MagentoFrameworkAppObjectManager;
use MagentoFrameworkEscaper;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoUiComponentListingColumnsColumn;

/**
 * Class AllsectionActions
 */
class AllsectionActions extends Column
{
    /** Url path */
    const CMS_URL_PATH_EDIT = 'section/allsection/edit';
    const CMS_URL_PATH_DELETE = 'section/allsection/delete';

    /**
     * @var MagentoFrameworkUrlInterface
     */
    protected $urlBuilder;

    /**
     * @var string
     */
    private $editUrl;

    /**
     * @var Escaper
     */
    private $escaper;

    /**
     * @param ContextInterface $context
     * @param UiComponentFactory $uiComponentFactory
     * @param UrlInterface $urlBuilder
     * @param array $components
     * @param array $data
     * @param string $editUrl
     */
    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        UrlInterface $urlBuilder,
        array $components = (),
        array $data = (),
        $editUrl = self::CMS_URL_PATH_EDIT
    ) {
        $this->urlBuilder = $urlBuilder;
        $this->editUrl = $editUrl;
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }

    /**
     * Prepare Data Source
     *
     * @param array $dataSource
     * @return array
     */
    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource('data')('items'))) {
            foreach ($dataSource('data')('items') as & $item) {
                $name = $this->getData('name');
                if (isset($item('layer_id'))) {
                    $item($name)('edit') = (
                        'href' => $this->urlBuilder->getUrl($this->editUrl, ('layer_id' => $item('layer_id'))),
                        'label' => __('Edit')
                    );
                    $title = $this->getEscaper()->escapeHtml($item('layer_name'));
                    $item($name)('delete') = (
                        'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_DELETE, ('layer_id' => $item('layer_id'))),
                        'label' => __('Delete'),
                        'confirm' => (
                            'title' => __('Delete %1', $title),
                            'message' => __('Are you sure you want to delete a %1 record?', $title)
                        )
                    );
                }
            }
        }

        return $dataSource;
    }

    /**
     * Get instance of escaper
     * @return Escaper
     * @deprecated 101.0.7
     */
    private function getEscaper()
    {
        if (!$this->escaper) {
            $this->escaper = ObjectManager::getInstance()->get(Escaper::class);
        }
        return $this->escaper;
    }
}
?>

what i am wrong?

magento2 – Unknown column ‘shipping_city’ in ‘where clause’ afterSearch Grid Table

I’m trying to use the afterSearch in a Admin Grid but when I try to filter a result I’m getting an Unknown column 'shipping_city' in 'where clause' where shipping_city is the custom column I added.

I found a sample here but just as the title state I’m getting an error. Below is my class that do this query and throws the error

class Grid
{
    public static $table = 'customer_entity';
    public static $leftJoinTable = 'customer_address_entity';

    public function afterSearch($intercepter, $collection)
    {
        if ($collection->getMainTable() === $collection->getConnection()->getTableName(self::$table)) {
            $leftJoinTableName = $collection->getConnection()->getTableName(self::$leftJoinTable);

            $collection
                ->getSelect()
                ->joinLeft(
                    ('co'=>$leftJoinTableName),
                    "co.entity_id = main_table.default_shipping",
                    ('shipping_city' => 'co.city')
                );

            $where = $collection->getSelect()->getPart(MagentoFrameworkDBSelect::WHERE);
            $collection->getSelect()->setPart(MagentoFrameworkDBSelect::WHERE, $where);
            // echo $collection->getSelect()->__toString();die;
        }
        return $collection;
    }
}

When trying to print the generated query I got this

SELECT `main_table`.*, `co`.`city` AS `shipping_city` FROM `customer_entity` AS `main_table`
LEFT JOIN `customer_address_entity` AS `co` ON co.entity_id = main_table.default_shipping 
WHERE (`shipping_city` LIKE '%Maidenhead%') 

As you can see the shipping_city is the custom column so whenever I tried to search in this column it’s passing this parameter. But I can’t get a result and it’s throwing an error. How can I fix this please.. badly need your help. Thanks

c# – Cómo poner en random las posiciones de los objetos dentro de un Grid Layout Group en UNITY?

intento intercambiar posiciones de 4 objetos, mejor si es aleatorio. Los objetos están dentro de un Grid Layout Group de Unity. O sea, cada que inicie se cambie la posición(donde esta el rojo aparezca el azul, donde esta el verde, el amarillo, etc.), por favor no sean duros con lo poco que avancé.
introducir la descripción de la imagen aquí

using UnityEngine;

using UnityEngine.UI;
using UnityEngine.UIElements;

public class CajitaRandom : MonoBehaviour
{
   
    public GridLayoutGroup cajita;
    void Start()
    {
        cajita.GetComponentInChildren<Position>(Random);
    }

layout – How do you set a grid when you have a sidebar?

I need to design a simple dashboard with a 240px sidebar menu for a 1440px screen size. The layout has to based on Bootstrap 4 Grid.

So I set a grid with a gutter of 30px – but how do I determine the total width of my grid? How do I determine the width of the container margins? enter image description here

css – Grid children swapping places when using grid-row-end

I am developing a grid layout for a list of cards. The expected result for the grid is displayed in this image:

Grid - Expected Result

I am expecting cards #1-6 to be displayed from left to right and top to bottom. In the case where there are more than 6 cards, every subsequent batch of 6 cards (#7-12, #13-18, …) will follow the same grid layout pattern as shown in the image above and will be displayed below the previous batch.

However, in the coding example shown below, cards #5 and #6 swap columns when the viewport width is 1200px or greater. At this breakpoint, card #5 is displayed in column #3 and card #6 is displayed in column #2. I am using grid-row-end for my grid children to achieve the masonry look, which I believe is the problem:

.thumbnail:nth-child(2n + 1) {
    grid-row-end: span 5;
}

.thumbnail:nth-child(2n) {
    grid-row-end: span 6;
}

I do not want to manually set every 5th and 6th child to swap columns as the number of cards rendered will be dynamic:

// I do not want to declare these styles.
.thumbnail:nth-child(5n) {
    grid-column: 2;
}

.thumbnail:nth-child(6n) {
    grid-row: 6 / 12;
    grid-column: 3;
}

Questions

  • Why are card #5 and #6 swapping columns?
  • Are there any changes I can make to my code to get the desired result?

const thumbnails = (
    { category: "Card 1", title: "Some title" },
    { category: "Card 2", title: "Some title" },
    { category: "Card 3", title: "Some title" },
    { category: "Card 4", title: "Some title" },
    { category: "Card 5", title: "Some title" },
    { category: "Card 6", title: "Some title" }
);

const Thumbnail = ({ category, title }) => (
    <li className="thumbnail">
        <div className="thumbnail__image-container"></div>
        <div className="thumbnail__metadata-container">
            <p>{category}</p>
            <h2>{title}</h2>
        </div>
    </li>
);

const Gallery = () => (
    <ul className="gallery">
        {thumbnails.map((thumbnail, i) => {
            return <Thumbnail key={`${thumbnail.title}-${i}`} {...thumbnail} />;
        })}
    </ul>
);

ReactDOM.render(<Gallery />, document.getElementById("app"));
* {
    margin: 0;
    padding: 0;
}

html {
    font-family: sans-serif;
}

.gallery {
    display: grid;
    list-style: none;
    grid-template-columns: repeat(1, 1fr);
    grid-gap: 14px;
    padding: 16px;
}

.thumbnail {
    display: flex;
    flex-direction: column;
}

.thumbnail__image-container {
    background: url("https://via.placeholder.com/150");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 125% auto;
    width: 100%;
    min-height: 200px;
    flex: 1;
}

.thumbnail__metadata-container {
    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 24px;
    background-color: lightblue;
    text-align: center;
}

@media (min-width: 768px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .gallery {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 60px;
        height: auto;
    }

    .thumbnail:nth-child(2n + 1) {
        grid-row-end: span 5;
    }

    .thumbnail:nth-child(2n) {
        grid-row-end: span 6;
    }

    .thumbnail__metadata-container {
        padding: 36px;
    }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="app"></div>

unity – How to render a grid of dots being exactly 1×1 pixel wide using a shader?

I would like to render a grid with many dots, all equally spaced and being exactly 1 pixel wide.
What I was able to achieve so far is this :

enter image description here

What I would like is (simulated using image editing program):

enter image description here

Here is the shader I wrote (which give result of 1st image).
This is rendered as a giant quad.

Shader "Custom/Grid"
{
    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct vertInput {
                float4 pos : POSITION;
                float4 uv : TEXCOORD1;
            };

            struct vertOutput {
                float4 pos : SV_POSITION;
                float4 uv : TEXCOORD0;
            };

            vertOutput vert (vertInput input)
            {
                vertOutput o;
                o.pos = mul(UNITY_MATRIX_MVP, input.pos);
                o.uv = input.uv;
                return o;
            }

            fixed4 frag (vertOutput output) : SV_Target
            {
                float4 uv = output.uv;
                float x = step((uv.x * 100.0 + 0.025) % 1.0, 0.05);
                float y = step((uv.y * 100.0 + 0.025) % 1.0, 0.05);
                float c = min(x, y);
                return float4(c, c, c, 1.0);
            }
            ENDCG
        }
    }
}

Is it possible to achieve what I want using a shader ?
What is needed from first draft is to control the size of each dot.
I have tried to use partial derivatives (ddx and ddy) but was not able to make it work.

theming – grid view width

Stack Exchange Network


Stack Exchange network consists of 177 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

c++ – LeetCode 1293: Shortest Path in a Grid with Obstacles Elimination

I’m posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so.

Problem

  • Given a m * n grid, where each cell is either 0 (empty) or 1 (obstacle). In one step, you can move up, down, left or right from and to an empty cell.

  • Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m-1, n-1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.

Example 1:

Input: 
grid = 
((0,0,0),
 (1,1,0),
 (0,0,0),
 (0,1,1),
 (0,0,0)), 
k = 1
Output: 6
Explanation: 
The shortest path without eliminating any obstacle is 10. 
The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).

Example 2:

Input: 
grid = 
((0,1,1),
 (1,1,1),
 (1,0,0)), 
k = 1
Output: -1
Explanation: 
We need to eliminate at least two obstacles to find such a walk.

Constraints:

  • grid.length == m
  • grid(0).length == n
  • 1 <= m, n <= 40
  • 1 <= k <= m*n
  • grid(i)(j) == 0 or 1
  • grid(0)(0) == grid(m-1)(n-1) == 0

Accepted Code

#include <array>
#include <string>
#include <vector>
#include <unordered_set>
#include <utility>
#include <algorithm>


class Solution {
public:
    inline int shortestPath(const std::vector<std::vector<int>>& grid, const int k) {
        if (grid.empty()) {
            return 0;
        }

        int path_distance = INT_MAX;
        get_manhattan_distance(0, -1, -1, 0, 0, k, grid, path_distance);
        return path_distance == INT_MAX ? -1 : path_distance;
    }

private:
    // Four neighbor cells
    static inline std::array<std::pair<int, int>, 4> directions = {{{0, 1}, {1, 0}, {0, -1}, { -1, 0}}};
    std::unordered_set<std::string> memo;

    // row - col - k string
    static inline std::string get_key(const int row, const int col, const int k) {
        return std::to_string(row) + "#" + std::to_string(col) + "#" + std::to_string(k);
    }

    // Calculate Manhattan distance 
    inline void get_manhattan_distance(const int path, const int prev_row, const int prev_col, const int row, const int col, int k, const std::vector<std::vector<int>>& grid, int& base_distance) {
        if (k >= get_row_length(grid) + get_col_length(grid) - 3 - row - col) {
            base_distance = min(base_distance, path + get_row_length(grid) + get_col_length(grid) - 2 - row - col);
            return;
        }

        if (row == get_row_length(grid) - 1 && col == get_col_length(grid) - 1) {
            base_distance = min(base_distance, path);
            return;
        }

        if (!memo.insert(get_key(row, col, k)).second) {
            return;
        }

        int curr_dist = get_distance(row, col, grid);

        for (const auto& direction : directions) {
            if (!(row + direction.first == prev_row && col + direction.second == prev_col) && is_valid(row + direction.first, col + direction.second, grid)) {
                int dist = get_distance(row + direction.first, col + direction.second, grid);

                if (grid(row + direction.first)(col + direction.second) == 0) {
                    get_manhattan_distance(path + 1, row, col, row + direction.first, col + direction.second, k, grid, base_distance);

                } else if (dist < curr_dist && k > 0) {
                    get_manhattan_distance(path + 1, row, col, row + direction.first, col + direction.second, k - 1, grid, base_distance);
                }
            }
        }
    }

    // Get Current distance
    static inline const int get_distance(const int row, const int col, const std::vector<std::vector<int>>& grid) {
        return std::abs(row - get_row_length(grid) - 1) + std::abs(col - get_col_length(grid) - 1);
    }

    // Check for grid boundaries
    static inline const bool is_valid(const int row, const int col, const std::vector<std::vector<int>>& grid) {
        return row > -1 && row < get_row_length(grid) && col > -1 && col < get_col_length(grid);
    }

    // Get grid row size
    static inline const int get_row_length(const std::vector<std::vector<int>>& grid) {
        return grid.size();
    }

    // Get grid column size
    static inline const int get_col_length(const std::vector<std::vector<int>>& grid) {
        return grid(0).size();
    }
};

Reference

LeetCode has a template for answering question. There is usually a class named Solution with one or more public functions which we are not allowed to rename.